Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -200,7 +200,8 @@ |
201 | 201 | # the only other things to check for are template and file differences in the output. |
202 | 202 | # (a) Check if the current output has a newer template/file used |
203 | 203 | # (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' ) ); |
205 | 206 | # Save to cache. This will be updated whenever the page is touched. |
206 | 207 | $data = FlaggedRevs::makeMemcObj( $synced ? "true" : "false" ); |
207 | 208 | $wgMemc->set( $key, $data, $wgParserCacheExpireTime ); |
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php |
— | — | @@ -451,11 +451,15 @@ |
452 | 452 | |
453 | 453 | /* |
454 | 454 | * 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. |
457 | 457 | * (b) newest( stable rev, rev at time of review ) if FR_INCLUDES_STABLE |
458 | 458 | * (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) |
460 | 464 | * |
461 | 465 | * @return Array of (template title, rev ID in reviewed version) tuples |
462 | 466 | */ |
— | — | @@ -464,15 +468,20 @@ |
465 | 469 | return array(); // short-circuit |
466 | 470 | } |
467 | 471 | $dbr = wfGetDB( DB_SLAVE ); |
468 | | - $ret = $dbr->select( array( 'flaggedtemplates', 'page', 'flaggedpages' ), |
| 472 | + $ret = $dbr->select( |
| 473 | + array( 'flaggedtemplates', 'templatelinks', 'page', 'flaggedpages' ), |
469 | 474 | 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 |
471 | 476 | __METHOD__, |
472 | 477 | array(), /* OPTIONS */ |
473 | 478 | 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', |
475 | 483 | '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 | + ) |
477 | 486 | ); |
478 | 487 | $tmpChanges = array(); |
479 | 488 | while ( $row = $dbr->fetchObject( $ret ) ) { |
— | — | @@ -497,31 +506,37 @@ |
498 | 507 | /* |
499 | 508 | * Fetch pending file changes for this reviewed page version. |
500 | 509 | * 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. |
502 | 511 | * (b) newest( stable rev, rev at time of review ) if FR_INCLUDES_STABLE |
503 | 512 | * (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) |
506 | 518 | * |
| 519 | + * @param string $noForeign Use 'noForeign' to skip Commons images (bug 15748) |
507 | 520 | * @return Array of (file title, MW file timestamp in reviewed version) tuples |
508 | 521 | */ |
509 | | - public function findPendingFileChanges() { |
| 522 | + public function findPendingFileChanges( $noForeign = false ) { |
510 | 523 | if ( FlaggedRevs::inclusionSetting() == FR_INCLUDES_CURRENT ) { |
511 | 524 | return array(); // short-circuit |
512 | 525 | } |
513 | 526 | $dbr = wfGetDB( DB_SLAVE ); |
514 | 527 | $ret = $dbr->select( |
515 | | - array( 'flaggedimages', 'page', 'flaggedpages', 'flaggedrevs' ), |
| 528 | + array( 'flaggedimages', 'imagelinks', 'page', 'flaggedpages', 'flaggedrevs' ), |
516 | 529 | 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 |
518 | 531 | __METHOD__, |
519 | 532 | array(), /* OPTIONS */ |
520 | 533 | 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', |
522 | 537 | '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' ) ) |
526 | 541 | ); |
527 | 542 | $fileChanges = array(); |
528 | 543 | while ( $row = $dbr->fetchObject( $ret ) ) { |
— | — | @@ -538,7 +553,11 @@ |
539 | 554 | # Compare to current... |
540 | 555 | $file = wfFindFile( $title ); // current file version |
541 | 556 | $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 | + } |
543 | 562 | if ( $deleted || $updated ) { |
544 | 563 | $fileChanges[] = array( $title, $tsStable ); |
545 | 564 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php |
— | — | @@ -1407,7 +1407,7 @@ |
1408 | 1408 | global $wgUser; |
1409 | 1409 | $skin = $wgUser->getSkin(); |
1410 | 1410 | $diffLinks = array(); |
1411 | | - $changes = $frev->findPendingFileChanges(); |
| 1411 | + $changes = $frev->findPendingFileChanges( 'noForeign' ); |
1412 | 1412 | foreach ( $changes as $tuple ) { |
1413 | 1413 | list( $title, $revIdStable ) = $tuple; |
1414 | 1414 | // @TODO: change when MW has file diffs |