r57621 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57620‎ | r57621 | r57622 >
Date:18:17, 10 October 2009
Author:aaron
Status:ok
Tags:
Comment:
merged r57620
Modified paths:
  • /branches/wmf-deployment/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /branches/wmf-deployment/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)

Diff [purge]

Index: branches/wmf-deployment/extensions/FlaggedRevs/FlaggedArticle.php
@@ -1,7 +1,8 @@
22 <?php
33
44 class FlaggedArticle extends Article {
5 - public $isDiffFromStable = false;
 5+ protected $isDiffFromStable = false;
 6+ protected $isMultiPageDiff = false;
67 protected $stableRev = null;
78 protected $pageConfig = null;
89 protected $flags = null;
@@ -873,17 +874,21 @@
874875 public function addReviewForm( &$data ) {
875876 global $wgRequest, $wgUser, $wgOut;
876877 # User must have review rights and page must be reviewable
877 - if( !$wgUser->isAllowed('review') || !$this->parent->exists() || !$this->isReviewable() ) {
 878+ if( !$wgUser->isAllowed('review') || !$this->parent->exists() || !$this->isReviewable() ) {
878879 return true;
879880 }
880881 # Unobtrusive patrolling UI only shows forms if requested
881882 if( !$wgRequest->getInt('reviewform') && $this->limitedUI() ) {
882883 return true;
883884 }
 885+ # Avoid multi-page diffs that are useless and misbehave (bug 19327)
 886+ if( $this->isMultiPageDiff ) {
 887+ return true;
 888+ }
884889 # Check action and if page is protected
885890 $action = $wgRequest->getVal( 'action', 'view' );
886 - # Must be view/diff action...and title must not be ambiguous
887 - if( !self::isViewAction($action) || !$wgRequest->getVal('title') ) {
 891+ # Must be view/diff action...
 892+ if( !self::isViewAction($action) ) {
888893 return true;
889894 }
890895 # Place the form at the top or bottom as most convenient
@@ -1249,18 +1254,34 @@
12501255 }
12511256
12521257 /**
 1258+ * Set $this->isDiffFromStable and $this->isMultiPageDiff fields
 1259+ */
 1260+ public function setViewFlags( $diff, $oldRev, $newRev ) {
 1261+ if( $newRev && $oldRev ) {
 1262+ // Is this a diff between two pages?
 1263+ if( $newRev->getPage() != $oldRev->getPage() ) {
 1264+ $this->isMultiPageDiff = true;
 1265+ // Is there a stable version?
 1266+ } else if( $this->isReviewable() ) {
 1267+ $frev = $this->getStableRev();
 1268+ // Is this a diff of the draft rev against the stable rev?
 1269+ if( $frev && $frev->getRevId() == $oldRev->getId() && $newRev->isCurrent() ) {
 1270+ $this->isDiffFromStable = true;
 1271+ }
 1272+ }
 1273+ }
 1274+ return true;
 1275+ }
 1276+
 1277+ /**
12531278 * Add a link to patrol non-reviewable pages.
12541279 * Also add a diff-to-stable for other pages if possible.
12551280 */
12561281 public function addDiffLink( $diff, $oldRev, $newRev ) {
12571282 global $wgUser, $wgOut;
12581283 // Is there a stable version?
1259 - if( $oldRev && $this->isReviewable() ) {
 1284+ if( $newRev && $oldRev && $this->isReviewable() ) {
12601285 $frev = $this->getStableRev();
1261 - # Is this a diff of the draft rev against the stable rev?
1262 - if( $frev && $frev->getRevId() == $oldRev->getID() && $newRev->isCurrent() ) {
1263 - $this->isDiffFromStable = true;
1264 - }
12651286 # Give a link to the diff-to-stable if needed
12661287 if( $frev && !$this->isDiffFromStable ) {
12671288 $article = new Article( $newRev->getTitle() );
Index: branches/wmf-deployment/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -1707,6 +1707,7 @@
17081708 public static function onDiffViewHeader( $diff, $oldRev, $newRev ) {
17091709 self::injectStyleAndJS();
17101710 $flaggedArticle = FlaggedArticle::getTitleInstance( $diff->getTitle() );
 1711+ $flaggedArticle->setViewFlags( $diff, $oldRev, $newRev );
17111712 $flaggedArticle->addDiffLink( $diff, $oldRev, $newRev );
17121713 $flaggedArticle->addDiffNoticeAndIncludes( $diff, $oldRev, $newRev );
17131714 return true;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r57620bug 21060: 'Box no longer shown for certain difflinks'aaron18:13, 10 October 2009

Status & tagging log