r63304 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63303‎ | r63304 | r63305 >
Date:23:59, 5 March 2010
Author:tstarling
Status:ok
Tags:
Comment:
Don't allow trackBlobs.php to continue if there is a potential for corruption as in bug 20757 or bug 22624.
Modified paths:
  • /trunk/phase3/maintenance/storage/trackBlobs.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/storage/trackBlobs.php
@@ -35,6 +35,7 @@
3636 }
3737
3838 function run() {
 39+ $this->checkIntegrity();
3940 $this->initTrackingTable();
4041 $this->trackRevisions();
4142 $this->trackOrphanText();
@@ -43,6 +44,47 @@
4445 }
4546 }
4647
 48+ function checkIntegrity() {
 49+ echo "Doing integrity check...\n";
 50+ $dbr = wfGetDB( DB_SLAVE );
 51+
 52+ // Scan for HistoryBlobStub objects in the text table (bug 20757)
 53+
 54+ $exists = $dbr->selectField( 'text', 1,
 55+ 'old_flags LIKE \'%object%\' AND old_flags NOT LIKE \'%external%\' ' .
 56+ 'AND LOWER(CONVERT(LEFT(old_text,22) USING latin1)) = \'o:15:"historyblobstub"\'',
 57+ __METHOD__
 58+ );
 59+
 60+ if ( $exists ) {
 61+ echo "Integrity check failed: found HistoryBlobStub objects in your text table.\n".
 62+ "This script could destroy these objects if it continued. Run resolveStubs.php\n" .
 63+ "to fix this.\n";
 64+ exit( 1 );
 65+ }
 66+
 67+ // Scan the archive table for HistoryBlobStub objects or external flags (bug 22624)
 68+ $flags = $dbr->selectField( 'archive', 'ar_flags',
 69+ 'ar_flags LIKE \'%external%\' OR (' .
 70+ 'ar_flags LIKE \'%object%\' ' .
 71+ 'AND LOWER(CONVERT(LEFT(ar_text,22) USING latin1)) = \'o:15:"historyblobstub"\' )',
 72+ __METHOD__
 73+ );
 74+
 75+ if ( strpos( $flags, 'external' ) !== false ) {
 76+ echo "Integrity check failed: found external storage pointers in your archive table.\n" .
 77+ "Run normaliseArchiveTable.php to fix this.\n";
 78+ exit( 1 );
 79+ } elseif ( $flags ) {
 80+ echo "Integrity check failed: found HistoryBlobStub objects in your archive table.\n" .
 81+ "These objects are probably already broken, continuing would make them\n" .
 82+ "unrecoverable. Run \"normaliseArchiveTable.php --fix-cgz-bug\" to fix this.\n";
 83+ exit( 1 );
 84+ }
 85+
 86+ echo "Integrity check OK\n";
 87+ }
 88+
4789 function initTrackingTable() {
4890 $dbw = wfGetDB( DB_MASTER );
4991 if ( $dbw->tableExists( 'blob_tracking' ) ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r62119Initial fix for bug 20757. Committing for test on server.tstarling07:01, 8 February 2010
r62124Fix script for bug 20757.tstarling12:36, 8 February 2010

Status & tagging log