summaryrefslogtreecommitdiff
path: root/maintenance/storage/checkStorage.php
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/storage/checkStorage.php')
-rw-r--r--maintenance/storage/checkStorage.php39
1 files changed, 18 insertions, 21 deletions
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