From: Tim Starling Date: Fri, 5 Mar 2010 23:59:42 +0000 (+0000) Subject: Don't allow trackBlobs.php to continue if there is a potential for corruption as... X-Git-Tag: 1.31.0-rc.0~37540 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%29%20.%20%22?a=commitdiff_plain;h=15f689d84313452ea99d229ad76d3c96dc264fe8;p=lhc%2Fweb%2Fwiklou.git Don't allow trackBlobs.php to continue if there is a potential for corruption as in bug 20757 or bug 22624. --- diff --git a/maintenance/storage/trackBlobs.php b/maintenance/storage/trackBlobs.php index 63327d5389..45d682e8bf 100644 --- a/maintenance/storage/trackBlobs.php +++ b/maintenance/storage/trackBlobs.php @@ -35,6 +35,7 @@ class TrackBlobs { } function run() { + $this->checkIntegrity(); $this->initTrackingTable(); $this->trackRevisions(); $this->trackOrphanText(); @@ -43,6 +44,47 @@ class TrackBlobs { } } + function checkIntegrity() { + echo "Doing integrity check...\n"; + $dbr = wfGetDB( DB_SLAVE ); + + // Scan for HistoryBlobStub objects in the text table (bug 20757) + + $exists = $dbr->selectField( 'text', 1, + 'old_flags LIKE \'%object%\' AND old_flags NOT LIKE \'%external%\' ' . + 'AND LOWER(CONVERT(LEFT(old_text,22) USING latin1)) = \'o:15:"historyblobstub"\'', + __METHOD__ + ); + + if ( $exists ) { + echo "Integrity check failed: found HistoryBlobStub objects in your text table.\n". + "This script could destroy these objects if it continued. Run resolveStubs.php\n" . + "to fix this.\n"; + exit( 1 ); + } + + // Scan the archive table for HistoryBlobStub objects or external flags (bug 22624) + $flags = $dbr->selectField( 'archive', 'ar_flags', + 'ar_flags LIKE \'%external%\' OR (' . + 'ar_flags LIKE \'%object%\' ' . + 'AND LOWER(CONVERT(LEFT(ar_text,22) USING latin1)) = \'o:15:"historyblobstub"\' )', + __METHOD__ + ); + + if ( strpos( $flags, 'external' ) !== false ) { + echo "Integrity check failed: found external storage pointers in your archive table.\n" . + "Run normaliseArchiveTable.php to fix this.\n"; + exit( 1 ); + } elseif ( $flags ) { + echo "Integrity check failed: found HistoryBlobStub objects in your archive table.\n" . + "These objects are probably already broken, continuing would make them\n" . + "unrecoverable. Run \"normaliseArchiveTable.php --fix-cgz-bug\" to fix this.\n"; + exit( 1 ); + } + + echo "Integrity check OK\n"; + } + function initTrackingTable() { $dbw = wfGetDB( DB_MASTER ); if ( $dbw->tableExists( 'blob_tracking' ) ) {