r68057 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68056‎ | r68057 | r68058 >
Date:03:53, 15 June 2010
Author:aaron
Status:deferred
Tags:
Comment:
* Rewrote stableVersionIsSynced() to use findPendingTemplateChanges()/findPendingFileChanges() functions. This assures that the diff page is consistent with the tabs. This is also waaay faster and should avoid some annoying sync bugs.
* This also handles file deletions (bug 23415).
* Removed image table from query - unused.
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevision.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php
@@ -474,7 +474,7 @@
475475 $revIdStable = max( $row->fp_stable, $row->ft_tmp_rev_id );
476476 # Compare to current...
477477 $deleted = ( !$revIdDraft && $revIdStable ); // later deleted
478 - $updated = ( $revIdDraft && $revIdDraft != $revIdStable ); // updated/created
 478+ $updated = ( $revIdDraft && $revIdDraft > $revIdStable ); // updated/created
479479 if ( $deleted || $updated ) {
480480 $tmpChanges[] = array( $title, $revIdStable );
481481 }
@@ -486,13 +486,14 @@
487487 * Fetch pending file changes for this reviewed page version.
488488 * For each file, the version used is newest( stable rev, rev at time of review ).
489489 * Pending changes exist if the latest version of the file is newer than this.
 490+ * @TODO: skip commons images, deliberately? (bug 15748).
490491 *
491492 * @return Array of (file title, MW file timestamp in reviewed version) tuples
492493 */
493494 public function findPendingFileChanges() {
494495 $dbr = wfGetDB( DB_SLAVE );
495496 $ret = $dbr->select(
496 - array( 'flaggedimages', 'page', 'image', 'flaggedpages', 'flaggedrevs' ),
 497+ array( 'flaggedimages', 'page', 'flaggedpages', 'flaggedrevs' ),
497498 array( 'fi_name', 'fi_img_timestamp', 'fr_img_timestamp' ),
498499 array( 'fi_rev_id' => $this->getRevId() ),
499500 __METHOD__,
@@ -500,7 +501,6 @@
501502 array(
502503 'page' => array( 'LEFT JOIN',
503504 'page_namespace = ' . NS_FILE . ' AND page_title = fi_name' ),
504 - 'image' => array( 'LEFT JOIN', 'img_name = fi_name' ),
505505 'flaggedpages' => array( 'LEFT JOIN', 'fp_page_id = page_id' ),
506506 'flaggedrevs' => array( 'LEFT JOIN',
507507 'fr_page_id = fp_page_id AND fr_rev_id = fp_stable' ) )
@@ -514,9 +514,9 @@
515515 ? $row->fr_img_timestamp
516516 : $reviewedTS;
517517 # Compare to current...
518 - $file = wfFindFile( $title );
 518+ $file = wfFindFile( $title ); // current file version
519519 $deleted = ( !$file && $tsStable ); // later deleted
520 - $updated = ( $file && $file->getTimestamp() != $tsStable ); // updated/created
 520+ $updated = ( $file && $file->getTimestamp() > $tsStable ); // updated/created
521521 if ( $deleted || $updated ) {
522522 $fileChanges[] = array( $title, $tsStable );
523523 }
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -150,15 +150,11 @@
151151 }
152152
153153 /**
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()
158156 * @return bool
159157 */
160 - public function stableVersionIsSynced(
161 - ParserOutput $stableOutput = null, ParserOutput $currentOutput = null
162 - ) {
 158+ public function stableVersionIsSynced() {
163159 global $wgUser, $wgMemc, $wgEnableParserCache, $wgParserCacheExpireTime;
164160 $srev = $this->getStableRev();
165161 if ( !$srev ) {
@@ -186,55 +182,11 @@
187183 } elseif ( $value === "false" ) {
188184 return false;
189185 }
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 - }
232186 # Since the stable and current revisions have the same text and only outputs,
233187 # the only other things to check for are template and file differences in the output.
234188 # (a) Check if the current output has a newer template/file used
235189 # (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() );
239191 # Save to cache. This will be updated whenever the page is touched.
240192 $data = FlaggedRevs::makeMemcObj( $synced ? "true" : "false" );
241193 $wgMemc->set( $key, $data, $wgParserCacheExpireTime );

Follow-up revisions

RevisionCommit summaryAuthorDate
r68058MFT r68032-r68057aaron03:57, 15 June 2010
r82917(bug 23415) Mark articles as needing review if a file version used in the sta...aaron22:01, 27 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r67964* Redid pending file/template checks. (bug 23415)...aaron21:48, 13 June 2010

Status & tagging log