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.php68
1 files changed, 51 insertions, 17 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;
}