Index: trunk/extensions/FlaggedRevs/maintenance/updateTracking.inc |
— | — | @@ -25,7 +25,8 @@ |
26 | 26 | echo "...doing fr_rev_id from $blockStart to $blockEnd\n"; |
27 | 27 | $cond = "rev_id BETWEEN $blockStart AND $blockEnd |
28 | 28 | 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'), |
30 | 31 | array('fr_rev_id','fr_tags','fr_quality','page_namespace','page_title', |
31 | 32 | 'fr_img_name','fr_img_timestamp','fr_img_sha1','rev_page'), |
32 | 33 | $cond, __FUNCTION__ |
— | — | @@ -35,21 +36,19 @@ |
36 | 37 | foreach ( $res as $row ) { |
37 | 38 | $tags = FlaggedRevision::expandRevisionTags( $row->fr_tags ); |
38 | 39 | # 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; |
45 | 45 | # 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 ) { |
47 | 47 | $irow = $db->selectRow( 'flaggedimages', |
48 | 48 | 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 ), |
51 | 50 | __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; |
54 | 53 | $file = $irow ? $row->page_title : null; |
55 | 54 | # Fill in from current if broken |
56 | 55 | if ( !$irow ) { |
— | — | @@ -57,27 +56,26 @@ |
58 | 57 | array( 'img_timestamp', 'img_sha1' ), |
59 | 58 | array( 'img_name' => $row->page_title ), |
60 | 59 | __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; |
63 | 62 | $file = $crow ? $row->page_title : null; |
64 | 63 | } |
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; |
70 | 64 | } |
| 65 | + |
| 66 | + # Check if anything needs updating |
71 | 67 | if ( $quality != $row->fr_quality |
72 | 68 | || $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 ) |
75 | 71 | { |
76 | 72 | # Update the row... |
77 | 73 | $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 | + ), |
82 | 80 | array( 'fr_rev_id' => $row->fr_rev_id, 'fr_page_id' => $row->rev_page ), |
83 | 81 | __FUNCTION__ |
84 | 82 | ); |