r68135 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68134‎ | r68135 | r68136 >
Date:21:20, 16 June 2010
Author:aaron
Status:ok
Tags:
Comment:
* Improved findPendingTemplateChanges()/findPendingFileChanges() for when source text changes are also pending
* (bug 15748) Except changed Commons images from sync check
* More doc comments
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevision.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -200,7 +200,8 @@
201201 # the only other things to check for are template and file differences in the output.
202202 # (a) Check if the current output has a newer template/file used
203203 # (b) Check if the stable version has a file/template that was deleted
204 - $synced = ( !$srev->findPendingTemplateChanges() && !$srev->findPendingFileChanges() );
 204+ $synced = ( !$srev->findPendingTemplateChanges()
 205+ && !$srev->findPendingFileChanges( 'noForeign' ) );
205206 # Save to cache. This will be updated whenever the page is touched.
206207 $data = FlaggedRevs::makeMemcObj( $synced ? "true" : "false" );
207208 $wgMemc->set( $key, $data, $wgParserCacheExpireTime );
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php
@@ -451,11 +451,15 @@
452452
453453 /*
454454 * Fetch pending template changes for this reviewed page version.
455 - * For each template, the version used is:
456 - * (a) (the latest rev) if FR_INCLUDES_CURRENT
 455+ * For each template, the "version used" is:
 456+ * (a) (the latest rev) if FR_INCLUDES_CURRENT. Might be non-existing.
457457 * (b) newest( stable rev, rev at time of review ) if FR_INCLUDES_STABLE
458458 * (c) ( rev at time of review ) if FR_INCLUDES_FREEZE
459 - * Pending changes exist if the latest version of the template is newer than this.
 459+ * Pending changes exist for a template iff the template is used in
 460+ * the current rev of this page and one of the following holds:
 461+ * (a) Current template is newer than the "version used" above (updated)
 462+ * (b) Current template exists and the "version used" was non-existing (created)
 463+ * (c) Current template doesn't exist and the "version used" existed (deleted)
460464 *
461465 * @return Array of (template title, rev ID in reviewed version) tuples
462466 */
@@ -464,15 +468,20 @@
465469 return array(); // short-circuit
466470 }
467471 $dbr = wfGetDB( DB_SLAVE );
468 - $ret = $dbr->select( array( 'flaggedtemplates', 'page', 'flaggedpages' ),
 472+ $ret = $dbr->select(
 473+ array( 'flaggedtemplates', 'templatelinks', 'page', 'flaggedpages' ),
469474 array( 'ft_namespace', 'ft_title', 'fp_stable', 'ft_tmp_rev_id', 'page_latest' ),
470 - array( 'ft_rev_id' => $this->getRevId() ),
 475+ array( 'ft_rev_id' => $this->getRevId() ), // template was in reviewed rev
471476 __METHOD__,
472477 array(), /* OPTIONS */
473478 array(
474 - 'page' => array( 'LEFT JOIN',
 479+ 'templatelinks' => array( 'INNER JOIN', // used in current rev
 480+ array( 'tl_from' => $this->getPage(),
 481+ 'tl_namespace = ft_namespace AND tl_title = ft_title' ) ),
 482+ 'page' => array( 'LEFT JOIN',
475483 'page_namespace = ft_namespace AND page_title = ft_title' ),
476 - 'flaggedpages' => array( 'LEFT JOIN', 'fp_page_id = page_id' ) )
 484+ 'flaggedpages' => array( 'LEFT JOIN', 'fp_page_id = page_id' )
 485+ )
477486 );
478487 $tmpChanges = array();
479488 while ( $row = $dbr->fetchObject( $ret ) ) {
@@ -497,31 +506,37 @@
498507 /*
499508 * Fetch pending file changes for this reviewed page version.
500509 * For each file, the version used is:
501 - * (a) (the latest rev) if FR_INCLUDES_CURRENT
 510+ * (a) (the latest rev) if FR_INCLUDES_CURRENT. Might be non-existing.
502511 * (b) newest( stable rev, rev at time of review ) if FR_INCLUDES_STABLE
503512 * (c) ( rev at time of review ) if FR_INCLUDES_FREEZE
504 - * Pending changes exist if the latest version of the file is newer than this.
505 - * @TODO: skip commons images, deliberately? (bug 15748).
 513+ * Pending changes exist for a file iff the file is used in
 514+ * the current rev of this page and one of the following holds:
 515+ * (a) Current file is newer than the "version used" above (updated)
 516+ * (b) Current file exists and the "version used" was non-existing (created)
 517+ * (c) Current file doesn't exist and the "version used" existed (deleted)
506518 *
 519+ * @param string $noForeign Use 'noForeign' to skip Commons images (bug 15748)
507520 * @return Array of (file title, MW file timestamp in reviewed version) tuples
508521 */
509 - public function findPendingFileChanges() {
 522+ public function findPendingFileChanges( $noForeign = false ) {
510523 if ( FlaggedRevs::inclusionSetting() == FR_INCLUDES_CURRENT ) {
511524 return array(); // short-circuit
512525 }
513526 $dbr = wfGetDB( DB_SLAVE );
514527 $ret = $dbr->select(
515 - array( 'flaggedimages', 'page', 'flaggedpages', 'flaggedrevs' ),
 528+ array( 'flaggedimages', 'imagelinks', 'page', 'flaggedpages', 'flaggedrevs' ),
516529 array( 'fi_name', 'fi_img_timestamp', 'fr_img_timestamp' ),
517 - array( 'fi_rev_id' => $this->getRevId() ),
 530+ array( 'fi_rev_id' => $this->getRevId() ), // template was in reviewed rev
518531 __METHOD__,
519532 array(), /* OPTIONS */
520533 array(
521 - 'page' => array( 'LEFT JOIN',
 534+ 'imagelinks' => array( 'INNER JOIN', // used in current rev
 535+ array( 'il_from' => $this->getPage(), 'il_to = fi_name' ) ),
 536+ 'page' => array( 'LEFT JOIN',
522537 'page_namespace = ' . NS_FILE . ' AND page_title = fi_name' ),
523 - 'flaggedpages' => array( 'LEFT JOIN', 'fp_page_id = page_id' ),
524 - 'flaggedrevs' => array( 'LEFT JOIN',
525 - 'fr_page_id = fp_page_id AND fr_rev_id = fp_stable' ) )
 538+ 'flaggedpages' => array( 'LEFT JOIN', 'fp_page_id = page_id' ),
 539+ 'flaggedrevs' => array( 'LEFT JOIN',
 540+ 'fr_page_id = fp_page_id AND fr_rev_id = fp_stable' ) )
526541 );
527542 $fileChanges = array();
528543 while ( $row = $dbr->fetchObject( $ret ) ) {
@@ -538,7 +553,11 @@
539554 # Compare to current...
540555 $file = wfFindFile( $title ); // current file version
541556 $deleted = ( !$file && $tsStable ); // later deleted
542 - $updated = ( $file && $file->getTimestamp() > $tsStable ); // updated/created
 557+ if ( $file && ( $noForeign !== 'noForeign' || $file->isLocal() ) ) {
 558+ $updated = ( $file->getTimestamp() > $tsStable ); // updated/created
 559+ } else {
 560+ $updated = false;
 561+ }
543562 if ( $deleted || $updated ) {
544563 $fileChanges[] = array( $title, $tsStable );
545564 }
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -1407,7 +1407,7 @@
14081408 global $wgUser;
14091409 $skin = $wgUser->getSkin();
14101410 $diffLinks = array();
1411 - $changes = $frev->findPendingFileChanges();
 1411+ $changes = $frev->findPendingFileChanges( 'noForeign' );
14121412 foreach ( $changes as $tuple ) {
14131413 list( $title, $revIdStable ) = $tuple;
14141414 // @TODO: change when MW has file diffs

Status & tagging log