From d9022f63880ce039446fba8364f68e656b7bf4cb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 3 May 2012 13:01:35 +0200 Subject: Update to MediaWiki 1.19.0 --- maintenance/storage/checkStorage.php | 39 ++++++++++++++----------------- maintenance/storage/compressOld.php | 19 ++++++++++++--- maintenance/storage/fixBug20757.php | 3 +++ maintenance/storage/recompressTracked.php | 7 ++++++ 4 files changed, 44 insertions(+), 24 deletions(-) (limited to 'maintenance/storage') diff --git a/maintenance/storage/checkStorage.php b/maintenance/storage/checkStorage.php index c372b9c4..af1f9ee2 100644 --- a/maintenance/storage/checkStorage.php +++ b/maintenance/storage/checkStorage.php @@ -21,8 +21,6 @@ * @ingroup Maintenance ExternalStorage */ -define( 'CONCAT_HEADER', 'O:27:"concatenatedgziphistoryblob"' ); - if ( !defined( 'MEDIAWIKI' ) ) { require_once( dirname( __FILE__ ) . '/../commandLine.inc' ); @@ -43,6 +41,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { * @ingroup Maintenance ExternalStorage */ class CheckStorage { + const CONCAT_HEADER = 'O:27:"concatenatedgziphistoryblob"'; var $oldIdMap, $errors; var $dbStore = null; @@ -55,15 +54,13 @@ class CheckStorage { ); function check( $fix = false, $xml = '' ) { - $fname = 'checkStorage'; $dbr = wfGetDB( DB_SLAVE ); if ( $fix ) { - $dbw = wfGetDB( DB_MASTER ); print "Checking, will fix errors if possible...\n"; } else { print "Checking...\n"; } - $maxRevId = $dbr->selectField( 'revision', 'MAX(rev_id)', false, $fname ); + $maxRevId = $dbr->selectField( 'revision', 'MAX(rev_id)', false, __METHOD__ ); $chunkSize = 1000; $flagStats = array(); $objectStats = array(); @@ -84,7 +81,7 @@ class CheckStorage { $this->oldIdMap = array(); $dbr->ping(); $res = $dbr->select( 'revision', array( 'rev_id', 'rev_text_id' ), - array( "rev_id BETWEEN $chunkStart AND $chunkEnd" ), $fname ); + array( "rev_id BETWEEN $chunkStart AND $chunkEnd" ), __METHOD__ ); foreach ( $res as $row ) { $this->oldIdMap[$row->rev_id] = $row->rev_text_id; } @@ -99,8 +96,11 @@ class CheckStorage { $externalRevs = array(); $objectRevs = array(); $res = $dbr->select( 'text', array( 'old_id', 'old_flags' ), - 'old_id IN (' . implode( ',', $this->oldIdMap ) . ')', $fname ); + 'old_id IN (' . implode( ',', $this->oldIdMap ) . ')', __METHOD__ ); foreach ( $res as $row ) { + /** + * @var $flags int + */ $flags = $row->old_flags; $id = $row->old_id; @@ -133,7 +133,7 @@ class CheckStorage { $dbw = wfGetDB( DB_MASTER ); $dbw->ping(); $dbw->update( 'text', array( 'old_flags' => '' ), - array( 'old_id' => $id ), $fname ); + array( 'old_id' => $id ), __METHOD__ ); echo "Fixed\n"; } else { $this->error( 'fixable', "Warning: old_flags set to 0", $id ); @@ -154,7 +154,7 @@ class CheckStorage { $externalNormalBlobs = array(); if ( count( $externalRevs ) ) { $res = $dbr->select( 'text', array( 'old_id', 'old_flags', 'old_text' ), - array( 'old_id IN (' . implode( ',', $externalRevs ) . ')' ), $fname ); + array( 'old_id IN (' . implode( ',', $externalRevs ) . ')' ), __METHOD__ ); foreach ( $res as $row ) { $urlParts = explode( '://', $row->old_text, 2 ); if ( count( $urlParts ) !== 2 || $urlParts[1] == '' ) { @@ -192,7 +192,7 @@ class CheckStorage { $blobsTable = $this->dbStore->getTable( $extDb ); $res = $extDb->select( $blobsTable, array( 'blob_id' ), - array( 'blob_id IN( ' . implode( ',', $blobIds ) . ')' ), $fname ); + array( 'blob_id IN( ' . implode( ',', $blobIds ) . ')' ), __METHOD__ ); foreach ( $res as $row ) { unset( $xBlobIds[$row->blob_id] ); } @@ -211,7 +211,7 @@ class CheckStorage { 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 ) . ')' ), $fname ); + array( 'old_id IN (' . implode( ',', $objectRevs ) . ')' ), __METHOD__ ); foreach ( $res as $row ) { $oldId = $row->old_id; $matches = array(); @@ -262,7 +262,7 @@ class CheckStorage { 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 ) ) . ')' ), $fname ); + array( 'old_id IN (' . implode( ',', array_keys( $concatBlobs ) ) . ')' ), __METHOD__ ); foreach ( $res as $row ) { $flags = explode( ',', $row->old_flags ); if ( in_array( 'external', $flags ) ) { @@ -285,7 +285,7 @@ class CheckStorage { $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( CONCAT_HEADER ) ), CONCAT_HEADER ) ) { + } 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 @@ -354,7 +354,6 @@ class CheckStorage { } function checkExternalConcatBlobs( $externalConcatBlobs ) { - $fname = 'CheckStorage::checkExternalConcatBlobs'; if ( !count( $externalConcatBlobs ) ) { return; } @@ -367,12 +366,12 @@ class CheckStorage { $blobIds = array_keys( $oldIds ); $extDb =& $this->dbStore->getSlave( $cluster ); $blobsTable = $this->dbStore->getTable( $extDb ); - $headerLength = strlen( CONCAT_HEADER ); + $headerLength = strlen( self::CONCAT_HEADER ); $res = $extDb->select( $blobsTable, array( 'blob_id', "LEFT(blob_text, $headerLength) AS header" ), - array( 'blob_id IN( ' . implode( ',', $blobIds ) . ')' ), $fname ); + array( 'blob_id IN( ' . implode( ',', $blobIds ) . ')' ), __METHOD__ ); foreach ( $res as $row ) { - if ( strcasecmp( $row->header, CONCAT_HEADER ) ) { + 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] ); } @@ -440,8 +439,6 @@ class CheckStorage { } function importRevision( &$revision, &$importer ) { - $fname = 'CheckStorage::importRevision'; - $id = $revision->getID(); $text = $revision->getText(); if ( $text === '' ) { @@ -462,7 +459,7 @@ class CheckStorage { // Find text row again $dbr = wfGetDB( DB_SLAVE ); - $oldId = $dbr->selectField( 'revision', 'rev_text_id', array( 'rev_id' => $id ), $fname ); + $oldId = $dbr->selectField( 'revision', 'rev_text_id', array( 'rev_id' => $id ), __METHOD__ ); if ( !$oldId ) { echo "Missing revision row for rev_id $id\n"; return; @@ -476,7 +473,7 @@ class CheckStorage { $dbw->update( 'text', array( 'old_flags' => $flags, 'old_text' => $text ), array( 'old_id' => $oldId ), - $fname, array( 'LIMIT' => 1 ) + __METHOD__, array( 'LIMIT' => 1 ) ); // Remove it from the unfixed list and add it to the fixed list diff --git a/maintenance/storage/compressOld.php b/maintenance/storage/compressOld.php index da82d93b..afe01458 100644 --- a/maintenance/storage/compressOld.php +++ b/maintenance/storage/compressOld.php @@ -70,7 +70,7 @@ class CompressOld extends Maintenance { $type = $this->getOption( 'type', 'concat' ); $chunkSize = $this->getOption( 'chunksize', 20 ); - $startId = $this->getOption( 'start-id', 0 ); + $startId = $this->getOption( 'startid', 0 ); $beginDate = $this->getOption( 'begin-date', '' ); $endDate = $this->getOption( 'end-date', '' ); $extDB = $this->getOption( 'extdb', '' ); @@ -123,7 +123,12 @@ class CompressOld extends Maintenance { } while( true ); } - /** @todo document */ + /** + * @todo document + * @param $row + * @param $extdb + * @return bool + */ private function compressPage( $row, $extdb ) { if ( false !== strpos( $row->old_flags, 'gzip' ) || false !== strpos( $row->old_flags, 'object' ) ) { #print "Already compressed row {$row->old_id}\n"; @@ -156,7 +161,15 @@ class CompressOld extends Maintenance { return true; } - /** @todo document */ + /** + * @param $startId + * @param $maxChunkSize + * @param $beginDate + * @param $endDate + * @param $extdb string + * @param $maxPageId bool|int + * @return bool + */ private function compressWithConcat( $startId, $maxChunkSize, $beginDate, $endDate, $extdb = "", $maxPageId = false ) { diff --git a/maintenance/storage/fixBug20757.php b/maintenance/storage/fixBug20757.php index b6def2da..cb2663d1 100644 --- a/maintenance/storage/fixBug20757.php +++ b/maintenance/storage/fixBug20757.php @@ -302,6 +302,9 @@ class FixBug20757 extends Maintenance { /** * 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 + * @return bool */ function isUnbrokenStub( $stub, $secondaryRow ) { $flags = explode( ',', $secondaryRow->old_flags ); diff --git a/maintenance/storage/recompressTracked.php b/maintenance/storage/recompressTracked.php index 09ab3e57..c8aac64b 100644 --- a/maintenance/storage/recompressTracked.php +++ b/maintenance/storage/recompressTracked.php @@ -169,6 +169,7 @@ class RecompressTracked { /** * Make sure the tracking table exists and isn't empty + * @return bool */ function checkTrackingTable() { $dbr = wfGetDB( DB_SLAVE ); @@ -588,6 +589,7 @@ class RecompressTracked { /** * Returns the name of the next target cluster + * @return string */ function getTargetCluster() { $cluster = next( $this->destClusters ); @@ -599,6 +601,8 @@ class RecompressTracked { /** * Gets a DB master connection for the given external cluster name + * @param $cluster string + * @return DatabaseBase */ function getExtDB( $cluster ) { $lb = wfGetLBFactory()->getExternalLB( $cluster ); @@ -684,6 +688,9 @@ class CgzCopyTransaction { /** * Add text. * Returns false if it's ready to commit. + * @param $text string + * @param $textId + * @return bool */ function addItem( $text, $textId ) { if ( !$this->cgz ) { -- cgit v1.2.2