r62688 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62687‎ | r62688 | r62689 >
Date:04:56, 19 February 2010
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
Resolve stubs which may be broken by running RCT. Added a --start option. Not tested yet.
Modified paths:
  • /trunk/phase3/maintenance/storage/fixBug20757.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/storage/fixBug20757.php
@@ -12,6 +12,7 @@
1313 parent::__construct();
1414 $this->mDescription = 'Script to fix bug 20757 assuming that blob_tracking is intact';
1515 $this->addOption( 'dry-run', 'Report only' );
 16+ $this->addOption( 'start', 'old_id to start at', false, true );
1617 }
1718
1819 function execute() {
@@ -23,7 +24,7 @@
2425 print "Dry run only.\n";
2526 }
2627
27 - $startId = 0;
 28+ $startId = $this->getOption( 'start', 0 );
2829 $numGood = 0;
2930 $numFixed = 0;
3031 $numBad = 0;
@@ -38,7 +39,7 @@
3940 array( 'old_id', 'old_flags', 'old_text' ),
4041 array(
4142 'old_id > ' . intval( $startId ),
42 - 'old_flags' => 'object'
 43+ 'old_flags ' . $dbr->buildLike( $dbr->anyString(), 'object', $dbr->anyString )
4344 ),
4445 __METHOD__,
4546 array(
@@ -72,14 +73,6 @@
7374 continue;
7475 }
7576
76 - // Check if it really is broken
77 - $text = Revision::getRevisionText( $row );
78 - if ( $text !== false ) {
79 - // Not broken yet
80 - ++$numGood;
81 - continue;
82 - }
83 -
8477 if ( strtolower( get_class( $obj ) ) !== 'historyblobstub' ) {
8578 print "{$row->old_id}: unrecoverable: unexpected object class " .
8679 get_class( $obj ) . "\n";
@@ -122,6 +115,7 @@
123116 foreach ( $stubs as $primaryId => $stub ) {
124117 $secondaryId = $stub['secondaryId'];
125118 if ( !isset( $trackedBlobs[$secondaryId] ) ) {
 119+ // No tracked blob. Work out what went wrong
126120 $secondaryRow = $dbr->selectRow(
127121 'text',
128122 array( 'old_flags', 'old_text' ),
@@ -130,12 +124,18 @@
131125 );
132126 if ( !$secondaryRow ) {
133127 print "$primaryId: unrecoverable: secondary row is missing\n";
 128+ ++$numBad;
 129+ } elseif ( $this->isUnbrokenStub( $stub, $secondaryRow ) ) {
 130+ // Not broken yet, and not in the tracked clusters so it won't get
 131+ // broken by the current RCT run.
 132+ ++$numGood;
134133 } elseif ( strpos( $secondaryRow->old_flags, 'external' ) !== false ) {
135134 print "$primaryId: unrecoverable: secondary gone to {$secondaryRow->old_text}\n";
 135+ ++$numBad;
136136 } else {
137137 print "$primaryId: unrecoverable: miscellaneous corruption of secondary row\n";
 138+ ++$numBad;
138139 }
139 - ++$numBad;
140140 unset( $stubs[$primaryId] );
141141 continue;
142142 }
@@ -212,7 +212,7 @@
213213 print "\n";
214214 print "Fixed: $numFixed\n";
215215 print "Unrecoverable: $numBad\n";
216 - print "Not yet broken: $numGood\n";
 216+ print "Good stubs: $numGood\n";
217217 }
218218
219219 function waitForSlaves() {
@@ -258,6 +258,43 @@
259259 return $this->mapCache[$pageId];
260260 }
261261
 262+ /**
 263+ * This is based on part of HistoryBlobStub::getText().
 264+ * Determine if the text can be retrieved from the row in the normal way.
 265+ */
 266+ function isUnbrokenStub( $stub, $secondaryRow ) {
 267+ $flags = explode( ',', $secondaryRow->old_flags );
 268+ if( in_array( 'external', $flags ) ) {
 269+ $url = $secondaryRow->old_text;
 270+ @list( /* $proto */ , $path ) = explode( '://', $url, 2 );
 271+ if ( $path == "" ) {
 272+ return false;
 273+ }
 274+ $secondaryRow->old_text = ExternalStore::fetchFromUrl( $url );
 275+ }
 276+ if( !in_array( 'object', $flags ) ) {
 277+ return false;
 278+ }
 279+
 280+ if( in_array( 'gzip', $flags ) ) {
 281+ $obj = unserialize( gzinflate( $secondaryRow->old_text ) );
 282+ } else {
 283+ $obj = unserialize( $secondaryRow->old_text );
 284+ }
 285+
 286+ if( !is_object( $obj ) ) {
 287+ // Correct for old double-serialization bug.
 288+ $obj = unserialize( $obj );
 289+ }
 290+
 291+ if ( !is_object( $obj ) ) {
 292+ return false;
 293+ }
 294+
 295+ $obj->uncompress();
 296+ $text = $obj->getItem( $stub['hash'] );
 297+ return $text !== false;
 298+ }
262299 }
263300
264301 $maintClass = 'FixBug20757';

Comments

#Comment by MarkAHershberger (talk | contribs)   20:05, 22 February 2010

tested in r62807

Status & tagging log