Index: trunk/extensions/FlaggedRevs/maintenance/updateLinks.inc |
— | — | @@ -7,7 +7,9 @@ |
8 | 8 | |
9 | 9 | $db = wfGetDB( DB_MASTER ); |
10 | 10 | |
11 | | - $start = $start ? $start : $db->selectField( 'revision', 'MIN(rev_id)', false, __FUNCTION__ ); |
| 11 | + if( $start === null ) { |
| 12 | + $start = $db->selectField( 'revision', 'MIN(rev_id)', false, __FUNCTION__ ); |
| 13 | + } |
12 | 14 | $end = $db->selectField( 'revision', 'MAX(rev_id)', false, __FUNCTION__ ); |
13 | 15 | if( is_null( $start ) || is_null( $end ) ){ |
14 | 16 | echo "...revision table seems to be empty.\n"; |
— | — | @@ -63,7 +65,11 @@ |
64 | 66 | $sha1 = $row->fr_img_sha1; |
65 | 67 | $file = $row->fr_img_name; |
66 | 68 | } |
67 | | - if( $file && ($file != $row->fr_img_name || $time != $row->fr_img_timestamp || $sha1 != $row->fr_img_sha1) ) { |
| 69 | + if( $file && |
| 70 | + ($file != $row->fr_img_name |
| 71 | + || $time != $row->fr_img_timestamp |
| 72 | + || $sha1 != $row->fr_img_sha1) ) |
| 73 | + { |
68 | 74 | $changed++; |
69 | 75 | } else if ( $quality != $row->fr_quality ) { |
70 | 76 | $changed++; |
— | — | @@ -137,6 +143,7 @@ |
138 | 144 | } |
139 | 145 | $count++; |
140 | 146 | } |
| 147 | + $db->freeResult( $res ); |
141 | 148 | # Remove manual config settings that simply restate the site defaults |
142 | 149 | $db->delete( 'flaggedpage_config', |
143 | 150 | array( "fpc_page_id BETWEEN $blockStart AND $blockEnd", |
— | — | @@ -162,7 +169,9 @@ |
163 | 170 | |
164 | 171 | $db = wfGetDB( DB_MASTER ); |
165 | 172 | |
166 | | - $start = $start ? $start : $db->selectField( 'flaggedtemplates', 'MIN(ft_rev_id)', false, __FUNCTION__ ); |
| 173 | + if( $start === null ) { |
| 174 | + $start = $db->selectField( 'flaggedtemplates', 'MIN(ft_rev_id)', false, __FUNCTION__ ); |
| 175 | + } |
167 | 176 | $end = $db->selectField( 'flaggedtemplates', 'MAX(ft_rev_id)', false, __FUNCTION__ ); |
168 | 177 | if( is_null( $start ) || is_null( $end ) ){ |
169 | 178 | echo "...flaggedtemplates table seems to be empty.\n"; |
— | — | @@ -182,7 +191,9 @@ |
183 | 192 | foreach( $res as $row ) { |
184 | 193 | $revision = Revision::newFromId( $row->ft_rev_id ); |
185 | 194 | # Replaces new fields into flaggedpages |
186 | | - $frev = $revision ? FlaggedRevision::newFromTitle( $revision->getTitle(), $row->ft_rev_id ) : null; |
| 195 | + $frev = $revision |
| 196 | + ? FlaggedRevision::newFromTitle( $revision->getTitle(), $row->ft_rev_id ) |
| 197 | + : null; |
187 | 198 | # Somethings broke? Delete the row... |
188 | 199 | if( !$frev ) { |
189 | 200 | $db->begin(); |
— | — | @@ -195,6 +206,7 @@ |
196 | 207 | } |
197 | 208 | $count++; |
198 | 209 | } |
| 210 | + $db->freeResult( $res ); |
199 | 211 | $blockStart += $BATCH_SIZE; |
200 | 212 | $blockEnd += $BATCH_SIZE; |
201 | 213 | wfWaitForSlaves( 5 ); |
— | — | @@ -209,7 +221,9 @@ |
210 | 222 | |
211 | 223 | $db = wfGetDB( DB_MASTER ); |
212 | 224 | |
213 | | - $start = $start ? $start : $db->selectField( 'flaggedimages', 'MIN(fi_rev_id)', false, __FUNCTION__ ); |
| 225 | + if( $start === null ) { |
| 226 | + $start = $db->selectField( 'flaggedimages', 'MIN(fi_rev_id)', false, __FUNCTION__ ); |
| 227 | + } |
214 | 228 | $end = $db->selectField( 'flaggedimages', 'MAX(fi_rev_id)', false, __FUNCTION__ ); |
215 | 229 | if( is_null( $start ) || is_null( $end ) ){ |
216 | 230 | echo "...flaggedimages table seems to be empty.\n"; |
— | — | @@ -229,7 +243,9 @@ |
230 | 244 | foreach( $res as $row ) { |
231 | 245 | $revision = Revision::newFromId( $row->fi_rev_id ); |
232 | 246 | # Replaces new fields into flaggedpages |
233 | | - $frev = $revision ? FlaggedRevision::newFromTitle( $revision->getTitle(), $row->fi_rev_id ) : null; |
| 247 | + $frev = $revision |
| 248 | + ? FlaggedRevision::newFromTitle( $revision->getTitle(), $row->fi_rev_id ) |
| 249 | + : null; |
234 | 250 | # Somethings broke? Delete the row... |
235 | 251 | if( !$frev ) { |
236 | 252 | $db->begin(); |
— | — | @@ -242,6 +258,7 @@ |
243 | 259 | } |
244 | 260 | $count++; |
245 | 261 | } |
| 262 | + $db->freeResult( $res ); |
246 | 263 | $blockStart += $BATCH_SIZE; |
247 | 264 | $blockEnd += $BATCH_SIZE; |
248 | 265 | wfWaitForSlaves( 5 ); |