http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96718
Revision: 96718
Author: demon
Date: 2011-09-10 07:17:10 +0000 (Sat, 10 Sep 2011)
Log Message:
-----------
Moved global define into class constant, replaced a bunch of $fname with
__METHOD__.
Modified Paths:
--------------
trunk/phase3/maintenance/storage/checkStorage.php
Modified: trunk/phase3/maintenance/storage/checkStorage.php
===================================================================
--- trunk/phase3/maintenance/storage/checkStorage.php 2011-09-10 07:15:51 UTC
(rev 96717)
+++ trunk/phase3/maintenance/storage/checkStorage.php 2011-09-10 07:17:10 UTC
(rev 96718)
@@ -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 @@
* @ingroup Maintenance ExternalStorage
*/
class CheckStorage {
+ const CONCAT_HEADER = 'O:27:"concatenatedgziphistoryblob"';
var $oldIdMap, $errors;
var $dbStore = null;
@@ -55,7 +54,6 @@
);
function check( $fix = false, $xml = '' ) {
- $fname = 'checkStorage';
$dbr = wfGetDB( DB_SLAVE );
if ( $fix ) {
$dbw = wfGetDB( DB_MASTER );
@@ -63,7 +61,7 @@
} 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 +82,7 @@
$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,7 +97,7 @@
$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 ) {
$flags = $row->old_flags;
$id = $row->old_id;
@@ -133,7 +131,7 @@
$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 +152,7 @@
$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 +190,7 @@
$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 +209,7 @@
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 +260,7 @@
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 +283,7 @@
$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 +352,6 @@
}
function checkExternalConcatBlobs( $externalConcatBlobs ) {
- $fname = 'CheckStorage::checkExternalConcatBlobs';
if ( !count( $externalConcatBlobs ) ) {
return;
}
@@ -367,12 +364,12 @@
$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 +437,6 @@
}
function importRevision( &$revision, &$importer ) {
- $fname = 'CheckStorage::importRevision';
-
$id = $revision->getID();
$text = $revision->getText();
if ( $text === '' ) {
@@ -462,7 +457,7 @@
// 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 +471,7 @@
$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
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs