diff options
Diffstat (limited to 'maintenance/storage')
-rw-r--r-- | maintenance/storage/checkStorage.php | 68 | ||||
-rw-r--r-- | maintenance/storage/compressOld.php | 99 | ||||
-rw-r--r-- | maintenance/storage/fixBug20757.php | 18 | ||||
-rw-r--r-- | maintenance/storage/orphanStats.php | 17 | ||||
-rw-r--r-- | maintenance/storage/recompressTracked.php | 73 | ||||
-rw-r--r-- | maintenance/storage/resolveStubs.php | 13 | ||||
-rw-r--r-- | maintenance/storage/testCompression.php | 6 | ||||
-rw-r--r-- | maintenance/storage/trackBlobs.php | 4 |
8 files changed, 218 insertions, 80 deletions
diff --git a/maintenance/storage/checkStorage.php b/maintenance/storage/checkStorage.php index 03dc113a..0f996625 100644 --- a/maintenance/storage/checkStorage.php +++ b/maintenance/storage/checkStorage.php @@ -34,7 +34,6 @@ if ( !defined( 'MEDIAWIKI' ) ) { $cs->check( $fix, $xml ); } - // ---------------------------------------------------------------------------------- /** @@ -212,8 +211,12 @@ class CheckStorage { $curIds = array(); if ( count( $objectRevs ) ) { $headerLength = 300; - $res = $dbr->select( 'text', array( 'old_id', 'old_flags', "LEFT(old_text, $headerLength) AS header" ), - array( 'old_id IN (' . implode( ',', $objectRevs ) . ')' ), __METHOD__ ); + $res = $dbr->select( + 'text', + array( 'old_id', 'old_flags', "LEFT(old_text, $headerLength) AS header" ), + array( 'old_id IN (' . implode( ',', $objectRevs ) . ')' ), + __METHOD__ + ); foreach ( $res as $row ) { $oldId = $row->old_id; $matches = array(); @@ -224,7 +227,11 @@ class CheckStorage { $className = strtolower( $matches[2] ); if ( strlen( $className ) != $matches[1] ) { - $this->error( 'restore text', "Error: invalid object header, wrong class name length", $oldId ); + $this->error( + 'restore text', + "Error: invalid object header, wrong class name length", + $oldId + ); continue; } @@ -263,8 +270,12 @@ class CheckStorage { $externalConcatBlobs = array(); if ( count( $concatBlobs ) ) { $headerLength = 300; - $res = $dbr->select( 'text', array( 'old_id', 'old_flags', "LEFT(old_text, $headerLength) AS header" ), - array( 'old_id IN (' . implode( ',', array_keys( $concatBlobs ) ) . ')' ), __METHOD__ ); + $res = $dbr->select( + 'text', + array( 'old_id', 'old_flags', "LEFT(old_text, $headerLength) AS header" ), + array( 'old_id IN (' . implode( ',', array_keys( $concatBlobs ) ) . ')' ), + __METHOD__ + ); foreach ( $res as $row ) { $flags = explode( ',', $row->old_flags ); if ( in_array( 'external', $flags ) ) { @@ -272,7 +283,11 @@ class CheckStorage { if ( in_array( 'object', $flags ) ) { $urlParts = explode( '/', $row->header ); if ( $urlParts[0] != 'DB:' ) { - $this->error( 'unfixable', "Error: unrecognised external storage type \"{$urlParts[0]}", $row->old_id ); + $this->error( + 'unfixable', + "Error: unrecognised external storage type \"{$urlParts[0]}", + $row->old_id + ); } else { $cluster = $urlParts[2]; $id = $urlParts[3]; @@ -284,12 +299,20 @@ class CheckStorage { ); } } else { - $this->error( 'unfixable', "Error: invalid flags \"{$row->old_flags}\" on concat bulk row {$row->old_id}", + $this->error( + 'unfixable', + "Error: invalid flags \"{$row->old_flags}\" on concat bulk row {$row->old_id}", $concatBlobs[$row->old_id] ); } - } elseif ( strcasecmp( substr( $row->header, 0, strlen( self::CONCAT_HEADER ) ), self::CONCAT_HEADER ) ) { - $this->error( 'restore text', "Error: Incorrect object header for concat bulk row {$row->old_id}", - $concatBlobs[$row->old_id] ); + } elseif ( strcasecmp( + substr( $row->header, 0, strlen( self::CONCAT_HEADER ) ), + self::CONCAT_HEADER + ) ) { + $this->error( + 'restore text', + "Error: Incorrect object header for concat bulk row {$row->old_id}", + $concatBlobs[$row->old_id] + ); } # else good unset( $concatBlobs[$row->old_id] ); @@ -299,7 +322,6 @@ class CheckStorage { // Check targets of unresolved stubs $this->checkExternalConcatBlobs( $externalConcatBlobs ); - // next chunk } @@ -331,7 +353,6 @@ class CheckStorage { } } - function error( $type, $msg, $ids ) { if ( is_array( $ids ) && count( $ids ) == 1 ) { $ids = reset( $ids ); @@ -374,17 +395,23 @@ class CheckStorage { array( 'blob_id IN( ' . implode( ',', $blobIds ) . ')' ), __METHOD__ ); foreach ( $res as $row ) { if ( strcasecmp( $row->header, self::CONCAT_HEADER ) ) { - $this->error( 'restore text', "Error: invalid header on target $cluster/{$row->blob_id} of two-part ES URL", - $oldIds[$row->blob_id] ); + $this->error( + 'restore text', + "Error: invalid header on target $cluster/{$row->blob_id} of two-part ES URL", + $oldIds[$row->blob_id] + ); } unset( $oldIds[$row->blob_id] ); - } $extDb->freeResult( $res ); // Print errors for missing blobs rows foreach ( $oldIds as $blobId => $oldIds2 ) { - $this->error( 'restore text', "Error: missing target $cluster/$blobId for two-part ES URL", $oldIds2 ); + $this->error( + 'restore text', + "Error: missing target $cluster/$blobId for two-part ES URL", + $oldIds2 + ); } } } @@ -405,6 +432,7 @@ class CheckStorage { // Write revision list if ( !file_put_contents( $revFileName, implode( "\n", $revIds ) ) ) { echo "Error writing revision list, can't restore text\n"; + return; } @@ -421,12 +449,14 @@ class CheckStorage { if ( $exitStatus ) { echo "mwdumper died with exit status $exitStatus\n"; + return; } $file = fopen( $filteredXmlFileName, 'r' ); if ( !$file ) { echo "Unable to open filtered XML file\n"; + return; } @@ -448,6 +478,7 @@ class CheckStorage { if ( $content === null ) { echo "Revision $id is broken, we have no content available\n"; + return; } @@ -459,12 +490,14 @@ class CheckStorage { // be safe, we'll skip it and leave it broken echo "Revision $id is blank in the dump, may have been broken before export\n"; + return; } if ( !$id ) { // No ID, can't import echo "No id tag in revision, can't import\n"; + return; } @@ -473,6 +506,7 @@ class CheckStorage { $oldId = $dbr->selectField( 'revision', 'rev_text_id', array( 'rev_id' => $id ), __METHOD__ ); if ( !$oldId ) { echo "Missing revision row for rev_id $id\n"; + return; } diff --git a/maintenance/storage/compressOld.php b/maintenance/storage/compressOld.php index 8cb55487..cfffbbca 100644 --- a/maintenance/storage/compressOld.php +++ b/maintenance/storage/compressOld.php @@ -59,12 +59,41 @@ class CompressOld extends Maintenance { parent::__construct(); $this->mDescription = 'Compress the text of a wiki'; $this->addOption( 'type', 'Set compression type to either: gzip|concat', false, true, 't' ); - $this->addOption( 'chunksize', 'Maximum number of revisions in a concat chunk', false, true, 'c' ); - $this->addOption( 'begin-date', 'Earliest date to check for uncompressed revisions', false, true, 'b' ); + $this->addOption( + 'chunksize', + 'Maximum number of revisions in a concat chunk', + false, + true, + 'c' + ); + $this->addOption( + 'begin-date', + 'Earliest date to check for uncompressed revisions', + false, + true, + 'b' + ); $this->addOption( 'end-date', 'Latest revision date to compress', false, true, 'e' ); - $this->addOption( 'startid', 'The id to start from (gzip -> text table, concat -> page table)', false, true, 's' ); - $this->addOption( 'extdb', 'Store specified revisions in an external cluster (untested)', false, true ); - $this->addOption( 'endid', 'The page_id to stop at (only when using concat compression type)', false, true, 'n' ); + $this->addOption( + 'startid', + 'The id to start from (gzip -> text table, concat -> page table)', + false, + true, + 's' + ); + $this->addOption( + 'extdb', + 'Store specified revisions in an external cluster (untested)', + false, + true + ); + $this->addOption( + 'endid', + 'The page_id to stop at (only when using concat compression type)', + false, + true, + 'n' + ); } public function execute() { @@ -107,23 +136,36 @@ class CompressOld extends Maintenance { } } - /** @todo document */ + /** + * @todo document + * @param int $start + * @param string $extdb + */ private function compressOldPages( $start = 0, $extdb = '' ) { $chunksize = 50; $this->output( "Starting from old_id $start...\n" ); $dbw = wfGetDB( DB_MASTER ); do { - $res = $dbw->select( 'text', array( 'old_id', 'old_flags', 'old_text' ), - "old_id>=$start", __METHOD__, array( 'ORDER BY' => 'old_id', 'LIMIT' => $chunksize, 'FOR UPDATE' ) ); + $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 ) { break; } + $last = $start; + foreach ( $res as $row ) { # print " {$row->old_id} - {$row->old_namespace}:{$row->old_title}\n"; $this->compressPage( $row, $extdb ); $last = $row->old_id; } + $start = $last + 1; # Deletion may leave long empty stretches $this->output( "$start...\n" ); } while ( true ); @@ -131,12 +173,14 @@ class CompressOld extends Maintenance { /** * @todo document - * @param $row - * @param $extdb + * @param stdClass $row + * @param string $extdb * @return bool */ private function compressPage( $row, $extdb ) { - if ( false !== strpos( $row->old_flags, 'gzip' ) || false !== strpos( $row->old_flags, 'object' ) ) { + if ( false !== strpos( $row->old_flags, 'gzip' ) + || false !== strpos( $row->old_flags, 'object' ) + ) { #print "Already compressed row {$row->old_id}\n"; return false; } @@ -150,6 +194,7 @@ class CompressOld extends Maintenance { $compress = $storeObj->store( $extdb, $compress ); if ( $compress === false ) { $this->error( "Unable to store object" ); + return false; } } @@ -164,21 +209,22 @@ class CompressOld extends Maintenance { ), __METHOD__, array( 'LIMIT' => 1 ) ); + return true; } /** - * @param $startId - * @param $maxChunkSize - * @param $beginDate - * @param $endDate - * @param $extdb string - * @param $maxPageId bool|int + * @param int $startId + * @param int $maxChunkSize + * @param string $beginDate + * @param string $endDate + * @param string $extdb + * @param bool|int $maxPageId * @return bool */ private function compressWithConcat( $startId, $maxChunkSize, $beginDate, - $endDate, $extdb = "", $maxPageId = false ) - { + $endDate, $extdb = "", $maxPageId = false + ) { $loadStyle = self::LS_CHUNKED; $dbr = wfGetDB( DB_SLAVE ); @@ -213,12 +259,15 @@ class CompressOld extends Maintenance { # overwriting bulk storage concat rows. Don't compress external references, because # the script doesn't yet delete rows from external storage. $conds = array( - 'old_flags NOT ' . $dbr->buildLike( $dbr->anyString(), 'object', $dbr->anyString() ) . ' AND old_flags NOT ' - . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ) ); + 'old_flags NOT ' . $dbr->buildLike( $dbr->anyString(), 'object', $dbr->anyString() ) + . ' AND old_flags NOT ' + . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ) + ); if ( $beginDate ) { if ( !preg_match( '/^\d{14}$/', $beginDate ) ) { $this->error( "Invalid begin date \"$beginDate\"\n" ); + return false; } $conds[] = "rev_timestamp>'" . $beginDate . "'"; @@ -226,6 +275,7 @@ class CompressOld extends Maintenance { if ( $endDate ) { if ( !preg_match( '/^\d{14}$/', $endDate ) ) { $this->error( "Invalid end date \"$endDate\"\n" ); + return false; } $conds[] = "rev_timestamp<'" . $endDate . "'"; @@ -303,8 +353,10 @@ class CompressOld extends Maintenance { $usedChunk = false; $primaryOldid = $revs[$i]->rev_text_id; + // @codingStandardsIgnoreStart Ignore avoid function calls in a FOR loop test part warning # Get the text of each revision and add it to the object for ( $j = 0; $j < $thisChunkSize && $chunk->isHappy(); $j++ ) { + // @codingStandardsIgnoreEnd $oldid = $revs[$i + $j]->rev_text_id; # Get text @@ -350,9 +402,10 @@ class CompressOld extends Maintenance { if ( $usedChunk ) { if ( $extdb != "" ) { # Move blob objects to External Storage - $stored = $storeObj->store( $extdb, serialize( $chunk )); + $stored = $storeObj->store( $extdb, serialize( $chunk ) ); if ( $stored === false ) { $this->error( "Unable to store object" ); + return false; } # Store External Storage URLs instead of Stub placeholders @@ -406,9 +459,9 @@ class CompressOld extends Maintenance { } $this->output( "\n" ); } + return true; } - } $maintClass = 'CompressOld'; diff --git a/maintenance/storage/fixBug20757.php b/maintenance/storage/fixBug20757.php index 101aa068..d2fe3b42 100644 --- a/maintenance/storage/fixBug20757.php +++ b/maintenance/storage/fixBug20757.php @@ -57,14 +57,9 @@ class FixBug20757 extends Maintenance { $totalRevs = $dbr->selectField( 'text', 'MAX(old_id)', false, __METHOD__ ); - if ( $dbr->getType() == 'mysql' - && version_compare( $dbr->getServerVersion(), '4.1.0', '>=' ) ) - { + if ( $dbr->getType() == 'mysql' ) { // In MySQL 4.1+, the binary field old_text has a non-working LOWER() function $lowerLeft = 'LOWER(CONVERT(LEFT(old_text,22) USING latin1))'; - } else { - // No CONVERT() in MySQL 4.0 - $lowerLeft = 'LOWER(LEFT(old_text,22))'; } while ( true ) { @@ -301,14 +296,15 @@ class FixBug20757 extends Maintenance { $this->mapCache[$pageId] = $map; $this->mapCacheSize += count( $map ); } + return $this->mapCache[$pageId]; } /** * This is based on part of HistoryBlobStub::getText(). * Determine if the text can be retrieved from the row in the normal way. - * @param $stub - * @param $secondaryRow + * @param array $stub + * @param stdClass $secondaryRow * @return bool */ function isUnbrokenStub( $stub, $secondaryRow ) { @@ -316,7 +312,10 @@ class FixBug20757 extends Maintenance { $text = $secondaryRow->old_text; if ( in_array( 'external', $flags ) ) { $url = $text; - @list( /* $proto */ , $path ) = explode( '://', $url, 2 ); + wfSuppressWarnings(); + list( /* $proto */, $path ) = explode( '://', $url, 2 ); + wfRestoreWarnings(); + if ( $path == "" ) { return false; } @@ -343,6 +342,7 @@ class FixBug20757 extends Maintenance { $obj->uncompress(); $text = $obj->getItem( $stub['hash'] ); + return $text !== false; } } diff --git a/maintenance/storage/orphanStats.php b/maintenance/storage/orphanStats.php index 1df1501e..c5213ad1 100644 --- a/maintenance/storage/orphanStats.php +++ b/maintenance/storage/orphanStats.php @@ -32,11 +32,13 @@ require_once __DIR__ . '/../Maintenance.php'; class OrphanStats extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = "how some statistics on the blob_orphans table, created with trackBlobs.php"; + $this->mDescription = + "Show some statistics on the blob_orphans table, created with trackBlobs.php"; } protected function &getDB( $cluster, $groups = array(), $wiki = false ) { $lb = wfGetLBFactory()->getExternalLB( $cluster ); + return $lb->getConnection( DB_SLAVE ); } @@ -54,12 +56,17 @@ class OrphanStats extends Maintenance { foreach ( $res as $boRow ) { $extDB = $this->getDB( $boRow->bo_cluster ); - $blobRow = $extDB->selectRow( 'blobs', '*', array( 'blob_id' => $boRow->bo_blob_id ), __METHOD__ ); + $blobRow = $extDB->selectRow( + 'blobs', + '*', + array( 'blob_id' => $boRow->bo_blob_id ), + __METHOD__ + ); $num++; $size = strlen( $blobRow->blob_text ); $totalSize += $size; - $hashes[ sha1( $blobRow->blob_text ) ] = true; + $hashes[sha1( $blobRow->blob_text )] = true; $maxSize = max( $size, $maxSize ); } unset( $res ); @@ -67,8 +74,8 @@ class OrphanStats extends Maintenance { $this->output( "Number of orphans: $num\n" ); if ( $num > 0 ) { $this->output( "Average size: " . round( $totalSize / $num, 0 ) . " bytes\n" . - "Max size: $maxSize\n" . - "Number of unique texts: " . count( $hashes ) . "\n" ); + "Max size: $maxSize\n" . + "Number of unique texts: " . count( $hashes ) . "\n" ); } } } diff --git a/maintenance/storage/recompressTracked.php b/maintenance/storage/recompressTracked.php index b2663165..910f56bd 100644 --- a/maintenance/storage/recompressTracked.php +++ b/maintenance/storage/recompressTracked.php @@ -27,14 +27,16 @@ require __DIR__ . '/../commandLine.inc'; if ( count( $args ) < 1 ) { echo "Usage: php recompressTracked.php [options] <cluster> [... <cluster>...] -Moves blobs indexed by trackBlobs.php to a specified list of destination clusters, and recompresses them in the process. Restartable. +Moves blobs indexed by trackBlobs.php to a specified list of destination clusters, +and recompresses them in the process. Restartable. Options: - --procs <procs> Set the number of child processes (default 1) - --copy-only Copy only, do not update the text table. Restart without this option to complete. - --debug-log <file> Log debugging data to the specified file - --info-log <file> Log progress messages to the specified file - --critical-log <file> Log error messages to the specified file + --procs <procs> Set the number of child processes (default 1) + --copy-only Copy only, do not update the text table. Restart + without this option to complete. + --debug-log <file> Log debugging data to the specified file + --info-log <file> Log progress messages to the specified file + --critical-log <file> Log error messages to the specified file "; exit( 1 ); } @@ -63,8 +65,15 @@ class RecompressTracked { public $debugLog, $infoLog, $criticalLog; public $store; - static $optionsWithArgs = array( 'procs', 'slave-id', 'debug-log', 'info-log', 'critical-log' ); - static $cmdLineOptionMap = array( + private static $optionsWithArgs = array( + 'procs', + 'slave-id', + 'debug-log', + 'info-log', + 'critical-log' + ); + + private static $cmdLineOptionMap = array( 'no-count' => 'noCount', 'procs' => 'numProcs', 'copy-only' => 'copyOnly', @@ -86,6 +95,7 @@ class RecompressTracked { $jobOptions[$classOption] = $options[$cmdOption]; } } + return new self( $jobOptions ); } @@ -109,7 +119,6 @@ class RecompressTracked { if ( $this->debugLog ) { $this->logToFile( $msg, $this->debugLog ); } - } function info( $msg ) { @@ -181,13 +190,16 @@ class RecompressTracked { $dbr = wfGetDB( DB_SLAVE ); if ( !$dbr->tableExists( 'blob_tracking' ) ) { $this->critical( "Error: blob_tracking table does not exist" ); + return false; } $row = $dbr->selectRow( 'blob_tracking', '*', false, __METHOD__ ); if ( !$row ) { $this->info( "Warning: blob_tracking table contains no rows, skipping this wiki." ); + return false; } + return true; } @@ -267,6 +279,7 @@ class RecompressTracked { if ( isset( $pipes[$slaveId] ) ) { $this->prevSlaveId = $slaveId; $this->dispatchToSlave( $slaveId, $args ); + return; } } @@ -276,6 +289,8 @@ class RecompressTracked { /** * Dispatch a command to a specified slave + * @param int $slaveId + * @param array|string $args */ function dispatchToSlave( $slaveId, $args ) { $args = (array)$args; @@ -339,6 +354,9 @@ class RecompressTracked { /** * Display a progress report + * @param string $label + * @param int $current + * @param int $end */ function report( $label, $current, $end ) { $this->numBatches++; @@ -434,14 +452,14 @@ class RecompressTracked { $args = explode( ' ', $line ); $cmd = array_shift( $args ); switch ( $cmd ) { - case 'doPage': - $this->doPage( intval( $args[0] ) ); - break; - case 'doOrphanList': - $this->doOrphanList( array_map( 'intval', $args ) ); - break; - case 'quit': - return; + case 'doPage': + $this->doPage( intval( $args[0] ) ); + break; + case 'doOrphanList': + $this->doOrphanList( array_map( 'intval', $args ) ); + break; + case 'quit': + return; } $this->waitForSlaves(); } @@ -449,6 +467,8 @@ class RecompressTracked { /** * Move tracked text in a given page + * + * @param int $pageId */ function doPage( $pageId ) { $title = Title::newFromId( $pageId ); @@ -527,6 +547,9 @@ class RecompressTracked { * without data loss. * * The transaction is kept short to reduce locking. + * + * @param int $textId + * @param string $url */ function moveTextRow( $textId, $url ) { if ( $this->copyOnly ) { @@ -560,6 +583,8 @@ class RecompressTracked { * * This function completes any moves that only have done bt_new_url. This * can happen when the script is interrupted, or when --copy-only is used. + * + * @param array $conds */ function finishIncompleteMoves( $conds ) { $dbr = wfGetDB( DB_SLAVE ); @@ -602,21 +627,25 @@ class RecompressTracked { if ( $cluster === false ) { $cluster = reset( $this->destClusters ); } + return $cluster; } /** * Gets a DB master connection for the given external cluster name - * @param $cluster string + * @param string $cluster * @return DatabaseBase */ function getExtDB( $cluster ) { $lb = wfGetLBFactory()->getExternalLB( $cluster ); + return $lb->getConnection( DB_MASTER ); } /** * Move an orphan text_id to the new cluster + * + * @param array $textIds */ function doOrphanList( $textIds ) { // Finish incomplete moves @@ -683,6 +712,8 @@ class CgzCopyTransaction { /** * Create a transaction from a RecompressTracked object + * @param RecompressTracked $parent + * @param string $blobClass */ function __construct( $parent, $blobClass ) { $this->blobClass = $blobClass; @@ -694,8 +725,8 @@ class CgzCopyTransaction { /** * Add text. * Returns false if it's ready to commit. - * @param $text string - * @param $textId + * @param string $text + * @param int $textId * @return bool */ function addItem( $text, $textId ) { @@ -706,6 +737,7 @@ class CgzCopyTransaction { $hash = $this->cgz->addItem( $text ); $this->referrers[$textId] = $hash; $this->texts[$textId] = $text; + return $this->cgz->isHappy(); } @@ -769,6 +801,7 @@ class CgzCopyTransaction { $this->critical( "Warning: concurrent operation detected, are there two conflicting " . "processes running, doing the same job?" ); } + return; } $this->recompress(); diff --git a/maintenance/storage/resolveStubs.php b/maintenance/storage/resolveStubs.php index e47d6407..290f1649 100644 --- a/maintenance/storage/resolveStubs.php +++ b/maintenance/storage/resolveStubs.php @@ -65,6 +65,9 @@ function resolveStubs() { /** * Resolve a history stub + * @param int $id + * @param string $stubText + * @param string $flags */ function resolveStub( $id, $stubText, $flags ) { $fname = 'resolveStub'; @@ -77,12 +80,18 @@ function resolveStub( $id, $stubText, $flags ) { if ( strtolower( get_class( $stub ) ) !== 'historyblobstub' ) { print "Error found object of class " . get_class( $stub ) . ", expecting historyblobstub\n"; + return; } # Get the (maybe) external row - $externalRow = $dbr->selectRow( 'text', array( 'old_text' ), - array( 'old_id' => $stub->mOldId, 'old_flags' . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ) ), + $externalRow = $dbr->selectRow( + 'text', + array( 'old_text' ), + array( + 'old_id' => $stub->mOldId, + 'old_flags' . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ) + ), $fname ); diff --git a/maintenance/storage/testCompression.php b/maintenance/storage/testCompression.php index fdc28d9b..f7ec6624 100644 --- a/maintenance/storage/testCompression.php +++ b/maintenance/storage/testCompression.php @@ -24,8 +24,9 @@ $optionsWithArgs = array( 'start', 'limit', 'type' ); require __DIR__ . '/../commandLine.inc'; -if ( !isset( $args[0] ) ) { - echo "Usage: php testCompression.php [--type=<type>] [--start=<start-date>] [--limit=<num-revs>] <page-title>\n"; +if ( !isset( $args[0] ) ) { + echo "Usage: php testCompression.php [--type=<type>] [--start=<start-date>] " . + "[--limit=<num-revs>] <page-title>\n"; exit( 1 ); } @@ -45,7 +46,6 @@ if ( isset( $options['limit'] ) ) { } $type = isset( $options['type'] ) ? $options['type'] : 'ConcatenatedGzipHistoryBlob'; - $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( array( 'page', 'revision', 'text' ), diff --git a/maintenance/storage/trackBlobs.php b/maintenance/storage/trackBlobs.php index 7857dd95..a3f93862 100644 --- a/maintenance/storage/trackBlobs.php +++ b/maintenance/storage/trackBlobs.php @@ -24,7 +24,6 @@ require __DIR__ . '/../commandLine.inc'; - if ( count( $args ) < 1 ) { echo "Usage: php trackBlobs.php <cluster> [... <cluster>]\n"; echo "Adds blobs from a given ES cluster to the blob_tracking table\n"; @@ -127,6 +126,7 @@ class TrackBlobs { $this->textClause .= 'old_text' . $dbr->buildLike( "DB://$cluster/", $dbr->anyString() ); } } + return $this->textClause; } @@ -134,6 +134,7 @@ class TrackBlobs { if ( !preg_match( '!^DB://(\w+)/(\d+)(?:/([0-9a-fA-F]+)|)$!', $text, $m ) ) { return false; } + return array( 'cluster' => $m[1], 'id' => intval( $m[2] ), @@ -306,6 +307,7 @@ class TrackBlobs { function findOrphanBlobs() { if ( !extension_loaded( 'gmp' ) ) { echo "Can't find orphan blobs, need bitfield support provided by GMP.\n"; + return; } |