r99615 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99614‎ | r99615 | r99616 >
Date:01:42, 12 October 2011
Author:aaron
Status:ok
Tags:
Comment:
Optimized cleanup script a bit and added simple logging
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/FlaggedRevs/maintenance/fixBug28348.inc (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/FlaggedRevs/maintenance/fixBug28348.inc
@@ -19,12 +19,20 @@
2020 $end += $BATCH_SIZE - 1;
2121 $blockStart = $start;
2222 $blockEnd = $start + $BATCH_SIZE - 1;
23 -
 23+
 24+ $logDump = '';
 25+
2426 $count = $changed = 0;
2527 while( $blockEnd <= $end ) {
2628 echo "...doing fi_rev_id from $blockStart to $blockEnd\n";
27 - $cond = "fi_rev_id BETWEEN $blockStart AND $blockEnd";
28 - $res = $db->select( 'flaggedimages', '*', $cond, __FUNCTION__ );
 29+ $cond = "fi_rev_id BETWEEN $blockStart AND $blockEnd" .
 30+ " AND fi_img_timestamp IS NOT NULL AND img_name IS NULL"; // optimize
 31+ $res = $db->select( array( 'flaggedimages', 'image' ), '*', $cond,
 32+ __FUNCTION__,
 33+ array(),
 34+ array( 'image' => array( 'LEFT JOIN',
 35+ 'img_sha1 = fi_img_sha1 AND img_timestamp = fi_img_timestamp' ) )
 36+ );
2937
3038 $db->begin();
3139 # Go through and clean up missing items, as well as correct fr_quality...
@@ -51,14 +59,19 @@
5260 __METHOD__
5361 );
5462 $changed++;
 63+ $logDump .= "{$row->fi_rev_id} {$row->fi_name} {$fi_img_timestamp}\n";
5564 }
5665 }
5766 }
5867 $db->commit();
 68+
5969 $db->freeResult( $res );
6070 $blockStart += $BATCH_SIZE;
6171 $blockEnd += $BATCH_SIZE;
6272 wfWaitForSlaves( 5 );
6373 }
 74+
 75+ file_put_contents( "bug28348-fixed-" . wfWikiID(), $logDump );
 76+
6477 echo "fi_img_timestamp column fixes complete ... {$count} rows [{$changed} changed]\n";
6578 }

Status & tagging log