From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- maintenance/storage/recompressTracked.php | 73 ++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 20 deletions(-) (limited to 'maintenance/storage/recompressTracked.php') 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] [... ...] -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 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 Log debugging data to the specified file - --info-log Log progress messages to the specified file - --critical-log Log error messages to the specified file + --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 Log debugging data to the specified file + --info-log Log progress messages to the specified file + --critical-log 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(); -- cgit v1.2.3-54-g00ecf