summaryrefslogtreecommitdiff
path: root/maintenance/storage
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/storage')
-rw-r--r--maintenance/storage/checkStorage.php18
-rw-r--r--maintenance/storage/compressOld.php35
-rw-r--r--maintenance/storage/dumpRev.php6
-rw-r--r--maintenance/storage/fixBug20757.php4
-rw-r--r--maintenance/storage/moveToExternal.php6
-rw-r--r--maintenance/storage/orphanStats.php4
-rw-r--r--maintenance/storage/recompressTracked.php4
-rw-r--r--maintenance/storage/resolveStubs.php2
-rw-r--r--maintenance/storage/storageTypeStats.php4
-rw-r--r--maintenance/storage/testCompression.php2
-rw-r--r--maintenance/storage/trackBlobs.php2
11 files changed, 48 insertions, 39 deletions
diff --git a/maintenance/storage/checkStorage.php b/maintenance/storage/checkStorage.php
index fd9393f2..03dc113a 100644
--- a/maintenance/storage/checkStorage.php
+++ b/maintenance/storage/checkStorage.php
@@ -22,7 +22,7 @@
*/
if ( !defined( 'MEDIAWIKI' ) ) {
- require_once( __DIR__ . '/../commandLine.inc' );
+ require_once __DIR__ . '/../commandLine.inc';
$cs = new CheckStorage;
$fix = isset( $options['fix'] );
@@ -75,7 +75,7 @@ class CheckStorage {
'fixable' => array(),
);
- for ( $chunkStart = 1 ; $chunkStart < $maxRevId; $chunkStart += $chunkSize ) {
+ for ( $chunkStart = 1; $chunkStart < $maxRevId; $chunkStart += $chunkSize ) {
$chunkEnd = $chunkStart + $chunkSize - 1;
// print "$chunkStart of $maxRevId\n";
@@ -443,18 +443,26 @@ class CheckStorage {
function importRevision( &$revision, &$importer ) {
$id = $revision->getID();
- $text = $revision->getText();
+ $content = $revision->getContent( Revision::RAW );
+ $id = $id ? $id : '';
+
+ if ( $content === null ) {
+ echo "Revision $id is broken, we have no content available\n";
+ return;
+ }
+
+ $text = $content->serialize();
if ( $text === '' ) {
// This is what happens if the revision was broken at the time the
// dump was made. Unfortunately, it also happens if the revision was
// legitimately blank, so there's no way to tell the difference. To
// be safe, we'll skip it and leave it broken
- $id = $id ? $id : '';
+
echo "Revision $id is blank in the dump, may have been broken before export\n";
return;
}
- if ( !$id ) {
+ if ( !$id ) {
// No ID, can't import
echo "No id tag in revision, can't import\n";
return;
diff --git a/maintenance/storage/compressOld.php b/maintenance/storage/compressOld.php
index d6362834..8cb55487 100644
--- a/maintenance/storage/compressOld.php
+++ b/maintenance/storage/compressOld.php
@@ -41,7 +41,7 @@
* @ingroup Maintenance ExternalStorage
*/
-require_once( __DIR__ . '/../Maintenance.php' );
+require_once __DIR__ . '/../Maintenance.php';
/**
* Maintenance script that compress the text of a wiki.
@@ -53,7 +53,7 @@ class CompressOld extends Maintenance {
* @todo document
*/
const LS_INDIVIDUAL = 0;
- const LS_CHUNKED = 1;
+ const LS_CHUNKED = 1;
public function __construct() {
parent::__construct();
@@ -113,9 +113,9 @@ class CompressOld extends Maintenance {
$this->output( "Starting from old_id $start...\n" );
$dbw = wfGetDB( DB_MASTER );
do {
- $res = $dbw->select( 'text', array( 'old_id','old_flags','old_text' ),
+ $res = $dbw->select( 'text', array( 'old_id', 'old_flags', 'old_text' ),
"old_id>=$start", __METHOD__, array( 'ORDER BY' => 'old_id', 'LIMIT' => $chunksize, 'FOR UPDATE' ) );
- if( $res->numRows() == 0 ) {
+ if ( $res->numRows() == 0 ) {
break;
}
$last = $start;
@@ -126,7 +126,7 @@ class CompressOld extends Maintenance {
}
$start = $last + 1; # Deletion may leave long empty stretches
$this->output( "$start...\n" );
- } while( true );
+ } while ( true );
}
/**
@@ -223,7 +223,7 @@ class CompressOld extends Maintenance {
}
$conds[] = "rev_timestamp>'" . $beginDate . "'";
}
- if ( $endDate ) {
+ if ( $endDate ) {
if ( !preg_match( '/^\d{14}$/', $endDate ) ) {
$this->error( "Invalid end date \"$endDate\"\n" );
return false;
@@ -254,8 +254,8 @@ class CompressOld extends Maintenance {
# Get the page row
$pageRes = $dbr->select( 'page',
- array('page_id', 'page_namespace', 'page_title','page_latest'),
- $pageConds + array('page_id' => $pageId), __METHOD__ );
+ array( 'page_id', 'page_namespace', 'page_title', 'page_latest' ),
+ $pageConds + array( 'page_id' => $pageId ), __METHOD__ );
if ( $pageRes->numRows() == 0 ) {
continue;
}
@@ -282,7 +282,7 @@ class CompressOld extends Maintenance {
$revs[] = $revRow;
}
- if ( count( $revs ) < 2) {
+ if ( count( $revs ) < 2 ) {
# No revisions matching, no further processing
$this->output( "\n" );
continue;
@@ -351,21 +351,22 @@ class CompressOld extends Maintenance {
if ( $extdb != "" ) {
# Move blob objects to External Storage
$stored = $storeObj->store( $extdb, serialize( $chunk ));
- if ($stored === false) {
- $this->error( "Unable to store object" );
+ if ( $stored === false ) {
+ $this->error( "Unable to store object" );
return false;
}
# Store External Storage URLs instead of Stub placeholders
- foreach ($stubs as $stub) {
- if ($stub===false)
+ foreach ( $stubs as $stub ) {
+ if ( $stub === false ) {
continue;
+ }
# $stored should provide base path to a BLOB
- $url = $stored."/".$stub->getHash();
+ $url = $stored . "/" . $stub->getHash();
$dbw->update( 'text',
array( /* SET */
'old_text' => $url,
'old_flags' => 'external,utf-8',
- ), array ( /* WHERE */
+ ), array( /* WHERE */
'old_id' => $stub->getReferrer(),
)
);
@@ -387,7 +388,7 @@ class CompressOld extends Maintenance {
if ( $stubs[$j] !== false && $revs[$i + $j]->rev_text_id != $primaryOldid ) {
$dbw->update( 'text',
array( /* SET */
- 'old_text' => serialize($stubs[$j]),
+ 'old_text' => serialize( $stubs[$j] ),
'old_flags' => 'object,utf-8',
), array( /* WHERE */
'old_id' => $revs[$i + $j]->rev_text_id
@@ -411,4 +412,4 @@ class CompressOld extends Maintenance {
}
$maintClass = 'CompressOld';
-require_once( RUN_MAINTENANCE_IF_MAIN );
+require_once RUN_MAINTENANCE_IF_MAIN;
diff --git a/maintenance/storage/dumpRev.php b/maintenance/storage/dumpRev.php
index 39f08f9d..f12bbd1b 100644
--- a/maintenance/storage/dumpRev.php
+++ b/maintenance/storage/dumpRev.php
@@ -21,7 +21,7 @@
* @ingroup Maintenance ExternalStorage
*/
-require_once( __DIR__ . '/../Maintenance.php' );
+require_once __DIR__ . '/../Maintenance.php';
/**
* Maintenance script that gets the text of a revision,
@@ -46,7 +46,7 @@ class DumpRev extends Maintenance {
$this->error( "Row not found", true );
}
- $flags = explode( ',', $row->old_flags );
+ $flags = explode( ',', $row->old_flags );
$text = $row->old_text;
if ( in_array( 'external', $flags ) ) {
$this->output( "External $text\n" );
@@ -85,4 +85,4 @@ class DumpRev extends Maintenance {
}
$maintClass = "DumpRev";
-require_once( RUN_MAINTENANCE_IF_MAIN );
+require_once RUN_MAINTENANCE_IF_MAIN;
diff --git a/maintenance/storage/fixBug20757.php b/maintenance/storage/fixBug20757.php
index 30cbcf1a..101aa068 100644
--- a/maintenance/storage/fixBug20757.php
+++ b/maintenance/storage/fixBug20757.php
@@ -21,7 +21,7 @@
* @ingroup Maintenance ExternalStorage
*/
-require_once( __DIR__ . '/../Maintenance.php' );
+require_once __DIR__ . '/../Maintenance.php';
/**
* Maintenance script to fix bug 20757.
@@ -348,4 +348,4 @@ class FixBug20757 extends Maintenance {
}
$maintClass = 'FixBug20757';
-require_once( RUN_MAINTENANCE_IF_MAIN );
+require_once RUN_MAINTENANCE_IF_MAIN;
diff --git a/maintenance/storage/moveToExternal.php b/maintenance/storage/moveToExternal.php
index 1049e0cc..348fb773 100644
--- a/maintenance/storage/moveToExternal.php
+++ b/maintenance/storage/moveToExternal.php
@@ -24,9 +24,9 @@
define( 'REPORTING_INTERVAL', 1 );
if ( !defined( 'MEDIAWIKI' ) ) {
- require_once( __DIR__ . '/../commandLine.inc' );
- require_once( __DIR__ . '/../../includes/externalstore/ExternalStoreDB.php' );
- require_once( 'resolveStubs.php' );
+ require_once __DIR__ . '/../commandLine.inc';
+ require_once __DIR__ . '/../../includes/externalstore/ExternalStoreDB.php';
+ require_once 'resolveStubs.php';
$fname = 'moveToExternal';
diff --git a/maintenance/storage/orphanStats.php b/maintenance/storage/orphanStats.php
index 4e246287..1df1501e 100644
--- a/maintenance/storage/orphanStats.php
+++ b/maintenance/storage/orphanStats.php
@@ -21,7 +21,7 @@
* @ingroup Maintenance ExternalStorage
*/
-require_once( __DIR__ . '/../Maintenance.php' );
+require_once __DIR__ . '/../Maintenance.php';
/**
* Maintenance script that shows some statistics on the blob_orphans table,
@@ -74,4 +74,4 @@ class OrphanStats extends Maintenance {
}
$maintClass = "OrphanStats";
-require_once( RUN_MAINTENANCE_IF_MAIN );
+require_once RUN_MAINTENANCE_IF_MAIN;
diff --git a/maintenance/storage/recompressTracked.php b/maintenance/storage/recompressTracked.php
index 030a147e..b2663165 100644
--- a/maintenance/storage/recompressTracked.php
+++ b/maintenance/storage/recompressTracked.php
@@ -23,7 +23,7 @@
*/
$optionsWithArgs = RecompressTracked::getOptionsWithArgs();
-require( __DIR__ . '/../commandLine.inc' );
+require __DIR__ . '/../commandLine.inc';
if ( count( $args ) < 1 ) {
echo "Usage: php recompressTracked.php [options] <cluster> [... <cluster>...]
@@ -279,7 +279,7 @@ class RecompressTracked {
*/
function dispatchToSlave( $slaveId, $args ) {
$args = (array)$args;
- $cmd = implode( ' ', $args );
+ $cmd = implode( ' ', $args );
fwrite( $this->slavePipes[$slaveId], "$cmd\n" );
}
diff --git a/maintenance/storage/resolveStubs.php b/maintenance/storage/resolveStubs.php
index 414eab81..e47d6407 100644
--- a/maintenance/storage/resolveStubs.php
+++ b/maintenance/storage/resolveStubs.php
@@ -27,7 +27,7 @@ define( 'REPORTING_INTERVAL', 100 );
if ( !defined( 'MEDIAWIKI' ) ) {
$optionsWithArgs = array( 'm' );
- require_once( __DIR__ . '/../commandLine.inc' );
+ require_once __DIR__ . '/../commandLine.inc';
resolveStubs();
}
diff --git a/maintenance/storage/storageTypeStats.php b/maintenance/storage/storageTypeStats.php
index 3187c318..e33057f6 100644
--- a/maintenance/storage/storageTypeStats.php
+++ b/maintenance/storage/storageTypeStats.php
@@ -19,7 +19,7 @@
* @ingroup Maintenance ExternalStorage
*/
-require_once( __DIR__ . '/../Maintenance.php' );
+require_once __DIR__ . '/../Maintenance.php';
class StorageTypeStats extends Maintenance {
function execute() {
@@ -112,4 +112,4 @@ SQL;
}
$maintClass = 'StorageTypeStats';
-require_once( RUN_MAINTENANCE_IF_MAIN );
+require_once RUN_MAINTENANCE_IF_MAIN;
diff --git a/maintenance/storage/testCompression.php b/maintenance/storage/testCompression.php
index e13e1b10..fdc28d9b 100644
--- a/maintenance/storage/testCompression.php
+++ b/maintenance/storage/testCompression.php
@@ -22,7 +22,7 @@
*/
$optionsWithArgs = array( 'start', 'limit', 'type' );
-require( __DIR__ . '/../commandLine.inc' );
+require __DIR__ . '/../commandLine.inc';
if ( !isset( $args[0] ) ) {
echo "Usage: php testCompression.php [--type=<type>] [--start=<start-date>] [--limit=<num-revs>] <page-title>\n";
diff --git a/maintenance/storage/trackBlobs.php b/maintenance/storage/trackBlobs.php
index 2f3c8c6a..7857dd95 100644
--- a/maintenance/storage/trackBlobs.php
+++ b/maintenance/storage/trackBlobs.php
@@ -22,7 +22,7 @@
* @see wfWaitForSlaves()
*/
-require( __DIR__ . '/../commandLine.inc' );
+require __DIR__ . '/../commandLine.inc';
if ( count( $args ) < 1 ) {