X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2Fstorage%2FfixBug20757.php;h=73c21d576a35cdd47415d5735ddc3056379fe58e;hb=f018c8135071c3f8bd9cf891acc0588222191372;hp=922d47259a38b66b037653e3c666e3c919817657;hpb=980d06840476638e379ca35da707d3a9084e2949;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/storage/fixBug20757.php b/maintenance/storage/fixBug20757.php index 922d47259a..73c21d576a 100644 --- a/maintenance/storage/fixBug20757.php +++ b/maintenance/storage/fixBug20757.php @@ -31,19 +31,29 @@ class FixBug20757 extends Maintenance { $totalRevs = $dbr->selectField( 'text', 'MAX(old_id)', false, __METHOD__ ); + if ( $dbr->getType() == 'mysql' + && version_compare( $dbr->getServerVersion(), '4.1.0', '>=' ) ) + { + // In MySQL 4.1+, the binary field old_text has a non-working LOWER() function + $lowerLeft = 'LOWER(CONVERT(LEFT(old_text,22) USING latin1))'; + } else { + // No CONVERT() in MySQL 4.0 + $lowerLeft = 'LOWER(LEFT(old_text,22))'; + } + while ( true ) { print "ID: $startId / $totalRevs\r"; $res = $dbr->select( 'text', array( 'old_id', 'old_flags', 'old_text' ), - array( + array( 'old_id > ' . intval( $startId ), 'old_flags LIKE \'%object%\' AND old_flags NOT LIKE \'%external%\'', - 'LOWER(CONVERT(LEFT(old_text,22) USING latin1)) = \'o:15:"historyblobstub"\'', + "$lowerLeft = 'o:15:\"historyblobstub\"'", ), __METHOD__, - array( + array( 'ORDER BY' => 'old_id', 'LIMIT' => $this->batchSize, ) @@ -68,7 +78,7 @@ class FixBug20757 extends Maintenance { } if ( !is_object( $obj ) ) { - print "{$row->old_id}: unrecoverable: unserialized to type " . + print "{$row->old_id}: unrecoverable: unserialized to type " . gettype( $obj ) . ", possible double-serialization\n"; ++$numBad; continue; @@ -120,15 +130,14 @@ class FixBug20757 extends Maintenance { } // Process the stubs - $stubsToFix = array(); foreach ( $stubs as $primaryId => $stub ) { $secondaryId = $stub['secondaryId']; if ( !isset( $trackedBlobs[$secondaryId] ) ) { // No tracked blob. Work out what went wrong - $secondaryRow = $dbr->selectRow( - 'text', + $secondaryRow = $dbr->selectRow( + 'text', array( 'old_flags', 'old_text' ), - array( 'old_id' => $secondaryId ), + array( 'old_id' => $secondaryId ), __METHOD__ ); if ( !$secondaryRow ) { @@ -255,7 +264,7 @@ class FixBug20757 extends Maintenance { $dbr = wfGetDB( DB_SLAVE ); $map = array(); - $res = $dbr->select( 'revision', + $res = $dbr->select( 'revision', array( 'rev_id', 'rev_text_id' ), array( 'rev_page' => $pageId ), __METHOD__ @@ -276,7 +285,7 @@ class FixBug20757 extends Maintenance { function isUnbrokenStub( $stub, $secondaryRow ) { $flags = explode( ',', $secondaryRow->old_flags ); $text = $secondaryRow->old_text; - if( in_array( 'external', $flags ) ) { + if ( in_array( 'external', $flags ) ) { $url = $text; @list( /* $proto */ , $path ) = explode( '://', $url, 2 ); if ( $path == "" ) { @@ -284,17 +293,17 @@ class FixBug20757 extends Maintenance { } $text = ExternalStore::fetchFromUrl( $url ); } - if( !in_array( 'object', $flags ) ) { + if ( !in_array( 'object', $flags ) ) { return false; } - if( in_array( 'gzip', $flags ) ) { + if ( in_array( 'gzip', $flags ) ) { $obj = unserialize( gzinflate( $text ) ); } else { $obj = unserialize( $text ); } - if( !is_object( $obj ) ) { + if ( !is_object( $obj ) ) { // Correct for old double-serialization bug. $obj = unserialize( $obj ); }