r86178 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86177‎ | r86178 | r86179 >
Date:03:29, 16 April 2011
Author:aaron
Status:ok
Tags:
Comment:
* Renamed file,time vars
* Used getLevelTier() function
Modified paths:
  • /trunk/extensions/FlaggedRevs/maintenance/updateTracking.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/maintenance/updateTracking.inc
@@ -25,7 +25,8 @@
2626 echo "...doing fr_rev_id from $blockStart to $blockEnd\n";
2727 $cond = "rev_id BETWEEN $blockStart AND $blockEnd
2828 AND fr_page_id = rev_page AND fr_rev_id = rev_id AND page_id = rev_page";
29 - $res = $db->select( array('revision','flaggedrevs','page'),
 29+ $res = $db->select(
 30+ array('revision','flaggedrevs','page'),
3031 array('fr_rev_id','fr_tags','fr_quality','page_namespace','page_title',
3132 'fr_img_name','fr_img_timestamp','fr_img_sha1','rev_page'),
3233 $cond, __FUNCTION__
@@ -35,21 +36,19 @@
3637 foreach ( $res as $row ) {
3738 $tags = FlaggedRevision::expandRevisionTags( $row->fr_tags );
3839 # Quality rating levels may have changed due to config tweaks...
39 - if ( FlaggedRevs::isPristine( $tags ) ) {
40 - $quality = 2;
41 - } else {
42 - $quality = FlaggedRevs::isQuality( $tags ) ? 1 : 0;
43 - }
44 - $time = $sha1 = $file = null;
 40+ $quality = max( 0, FlaggedRevs::getLevelTier( $tags ) );
 41+
 42+ $file = $row->fr_img_name;
 43+ $fileTime = $row->fr_img_timestamp;
 44+ $fileSha1 = $row->fr_img_sha1;
4545 # Check for file version to see if it's stored the old way...
46 - if ( !$row->fr_img_name && $row->page_namespace == NS_FILE ) {
 46+ if ( $row->page_namespace == NS_FILE && !$file ) {
4747 $irow = $db->selectRow( 'flaggedimages',
4848 array( 'fi_img_timestamp', 'fi_img_sha1' ),
49 - array( 'fi_rev_id' => $row->fr_rev_id,
50 - 'fi_name' => $row->page_title ),
 49+ array( 'fi_rev_id' => $row->fr_rev_id, 'fi_name' => $row->page_title ),
5150 __METHOD__ );
52 - $time = $irow ? $irow->fi_img_timestamp : null;
53 - $sha1 = $irow ? $irow->fi_img_sha1 : null;
 51+ $fileTime = $irow ? $irow->fi_img_timestamp : null;
 52+ $fileSha1 = $irow ? $irow->fi_img_sha1 : null;
5453 $file = $irow ? $row->page_title : null;
5554 # Fill in from current if broken
5655 if ( !$irow ) {
@@ -57,27 +56,26 @@
5857 array( 'img_timestamp', 'img_sha1' ),
5958 array( 'img_name' => $row->page_title ),
6059 __METHOD__ );
61 - $time = $crow ? $crow->img_timestamp : null;
62 - $sha1 = $crow ? $crow->img_sha1 : null;
 60+ $fileTime = $crow ? $crow->img_timestamp : null;
 61+ $fileSha1 = $crow ? $crow->img_sha1 : null;
6362 $file = $crow ? $row->page_title : null;
6463 }
65 - # Leave it alone if already set
66 - } elseif ( $row->fr_img_name && $row->page_namespace == NS_FILE ) {
67 - $time = $row->fr_img_timestamp;
68 - $sha1 = $row->fr_img_sha1;
69 - $file = $row->fr_img_name;
7064 }
 65+
 66+ # Check if anything needs updating
7167 if ( $quality != $row->fr_quality
7268 || $file != $row->fr_img_name
73 - || $sha1 != $row->fr_img_sha1
74 - || $time != $row->fr_img_timestamp )
 69+ || $fileSha1 != $row->fr_img_sha1
 70+ || $fileTime != $row->fr_img_timestamp )
7571 {
7672 # Update the row...
7773 $db->update( 'flaggedrevs',
78 - array( 'fr_quality' => $quality,
79 - 'fr_img_name' => $file,
80 - 'fr_img_sha1' => $sha1,
81 - 'fr_img_timestamp' => $time ),
 74+ array(
 75+ 'fr_quality' => $quality,
 76+ 'fr_img_name' => $file,
 77+ 'fr_img_sha1' => $fileSha1,
 78+ 'fr_img_timestamp' => $fileTime
 79+ ),
8280 array( 'fr_rev_id' => $row->fr_rev_id, 'fr_page_id' => $row->rev_page ),
8381 __FUNCTION__
8482 );

Status & tagging log