Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php |
— | — | @@ -474,7 +474,7 @@ |
475 | 475 | $revIdStable = max( $row->fp_stable, $row->ft_tmp_rev_id ); |
476 | 476 | # Compare to current... |
477 | 477 | $deleted = ( !$revIdDraft && $revIdStable ); // later deleted |
478 | | - $updated = ( $revIdDraft && $revIdDraft != $revIdStable ); // updated/created |
| 478 | + $updated = ( $revIdDraft && $revIdDraft > $revIdStable ); // updated/created |
479 | 479 | if ( $deleted || $updated ) { |
480 | 480 | $tmpChanges[] = array( $title, $revIdStable ); |
481 | 481 | } |
— | — | @@ -486,13 +486,14 @@ |
487 | 487 | * Fetch pending file changes for this reviewed page version. |
488 | 488 | * For each file, the version used is newest( stable rev, rev at time of review ). |
489 | 489 | * Pending changes exist if the latest version of the file is newer than this. |
| 490 | + * @TODO: skip commons images, deliberately? (bug 15748). |
490 | 491 | * |
491 | 492 | * @return Array of (file title, MW file timestamp in reviewed version) tuples |
492 | 493 | */ |
493 | 494 | public function findPendingFileChanges() { |
494 | 495 | $dbr = wfGetDB( DB_SLAVE ); |
495 | 496 | $ret = $dbr->select( |
496 | | - array( 'flaggedimages', 'page', 'image', 'flaggedpages', 'flaggedrevs' ), |
| 497 | + array( 'flaggedimages', 'page', 'flaggedpages', 'flaggedrevs' ), |
497 | 498 | array( 'fi_name', 'fi_img_timestamp', 'fr_img_timestamp' ), |
498 | 499 | array( 'fi_rev_id' => $this->getRevId() ), |
499 | 500 | __METHOD__, |
— | — | @@ -500,7 +501,6 @@ |
501 | 502 | array( |
502 | 503 | 'page' => array( 'LEFT JOIN', |
503 | 504 | 'page_namespace = ' . NS_FILE . ' AND page_title = fi_name' ), |
504 | | - 'image' => array( 'LEFT JOIN', 'img_name = fi_name' ), |
505 | 505 | 'flaggedpages' => array( 'LEFT JOIN', 'fp_page_id = page_id' ), |
506 | 506 | 'flaggedrevs' => array( 'LEFT JOIN', |
507 | 507 | 'fr_page_id = fp_page_id AND fr_rev_id = fp_stable' ) ) |
— | — | @@ -514,9 +514,9 @@ |
515 | 515 | ? $row->fr_img_timestamp |
516 | 516 | : $reviewedTS; |
517 | 517 | # Compare to current... |
518 | | - $file = wfFindFile( $title ); |
| 518 | + $file = wfFindFile( $title ); // current file version |
519 | 519 | $deleted = ( !$file && $tsStable ); // later deleted |
520 | | - $updated = ( $file && $file->getTimestamp() != $tsStable ); // updated/created |
| 520 | + $updated = ( $file && $file->getTimestamp() > $tsStable ); // updated/created |
521 | 521 | if ( $deleted || $updated ) { |
522 | 522 | $fileChanges[] = array( $title, $tsStable ); |
523 | 523 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -150,15 +150,11 @@ |
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | | - * Check if the stable version is synced with the current revision. |
155 | | - * Note: This function can be pretty expensive... |
156 | | - * @param ParserOutput $stableOutput, will fetch if not given |
157 | | - * @param ParserOutput $currentOutput, will fetch if not given |
| 154 | + * Checks if the stable version is synced with the current revision |
| 155 | + * Note: slower than getPendingRevCount() |
158 | 156 | * @return bool |
159 | 157 | */ |
160 | | - public function stableVersionIsSynced( |
161 | | - ParserOutput $stableOutput = null, ParserOutput $currentOutput = null |
162 | | - ) { |
| 158 | + public function stableVersionIsSynced() { |
163 | 159 | global $wgUser, $wgMemc, $wgEnableParserCache, $wgParserCacheExpireTime; |
164 | 160 | $srev = $this->getStableRev(); |
165 | 161 | if ( !$srev ) { |
— | — | @@ -186,55 +182,11 @@ |
187 | 183 | } elseif ( $value === "false" ) { |
188 | 184 | return false; |
189 | 185 | } |
190 | | - # If parseroutputs not given, fetch them... |
191 | | - if ( is_null( $stableOutput ) || !isset( $stableOutput->fr_newestTemplateID ) ) { |
192 | | - # Get parsed stable version |
193 | | - $anon = new User(); // anon cache most likely to exist |
194 | | - $stableOutput = FlaggedRevs::getPageCache( $this, $anon ); |
195 | | - if ( $stableOutput == false && $wgUser->getId() ) { |
196 | | - $stableOutput = FlaggedRevs::getPageCache( $this, $wgUser ); |
197 | | - } |
198 | | - # Regenerate the parser output as needed... |
199 | | - if ( $stableOutput == false ) { |
200 | | - $text = $srev->getRevText(); |
201 | | - $stableOutput = FlaggedRevs::parseStableText( $this, $text, $srev->getRevId() ); |
202 | | - # Update the stable version cache |
203 | | - FlaggedRevs::updatePageCache( $this, $anon, $stableOutput ); |
204 | | - } |
205 | | - } |
206 | | - if ( is_null( $currentOutput ) || !isset( $currentOutput->fr_newestTemplateID ) ) { |
207 | | - # Get parsed current version |
208 | | - $parserCache = ParserCache::singleton(); |
209 | | - $currentOutput = false; |
210 | | - $anon = new User(); // anon cache most likely to exist |
211 | | - # If $text is set, then the stableOutput is new. In that case, |
212 | | - # the current must also be new to avoid sync goofs. |
213 | | - if ( !isset( $text ) ) { |
214 | | - $currentOutput = $parserCache->get( $this, $anon ); |
215 | | - if ( $currentOutput == false && $wgUser->getId() ) { |
216 | | - $currentOutput = $parserCache->get( $this, $wgUser ); |
217 | | - } |
218 | | - } |
219 | | - # Regenerate the parser output as needed... |
220 | | - if ( $currentOutput == false ) { |
221 | | - global $wgParser; |
222 | | - $source = $this->getContent(); |
223 | | - $options = FlaggedRevs::makeParserOptions( $anon ); |
224 | | - $currentOutput = $wgParser->parse( $source, $this->getTitle(), |
225 | | - $options, /*$lineStart*/true, /*$clearState*/true, $this->getLatest() ); |
226 | | - # Might as well save the cache while we're at it |
227 | | - if ( $wgEnableParserCache ) { |
228 | | - $parserCache->save( $currentOutput, $this, $anon ); |
229 | | - } |
230 | | - } |
231 | | - } |
232 | 186 | # Since the stable and current revisions have the same text and only outputs, |
233 | 187 | # the only other things to check for are template and file differences in the output. |
234 | 188 | # (a) Check if the current output has a newer template/file used |
235 | 189 | # (b) Check if the stable version has a file/template that was deleted |
236 | | - $synced = ( |
237 | | - FlaggedRevs::includesAreSynced( $stableOutput, $currentOutput ) |
238 | | - ); |
| 190 | + $synced = ( !$srev->findPendingTemplateChanges() && !$srev->findPendingFileChanges() ); |
239 | 191 | # Save to cache. This will be updated whenever the page is touched. |
240 | 192 | $data = FlaggedRevs::makeMemcObj( $synced ? "true" : "false" ); |
241 | 193 | $wgMemc->set( $key, $data, $wgParserCacheExpireTime ); |