Index: branches/wmf-deployment/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -1,7 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class FlaggedArticle extends Article { |
5 | | - public $isDiffFromStable = false; |
| 5 | + protected $isDiffFromStable = false; |
| 6 | + protected $isMultiPageDiff = false; |
6 | 7 | protected $stableRev = null; |
7 | 8 | protected $pageConfig = null; |
8 | 9 | protected $flags = null; |
— | — | @@ -873,17 +874,21 @@ |
874 | 875 | public function addReviewForm( &$data ) { |
875 | 876 | global $wgRequest, $wgUser, $wgOut; |
876 | 877 | # 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() ) { |
878 | 879 | return true; |
879 | 880 | } |
880 | 881 | # Unobtrusive patrolling UI only shows forms if requested |
881 | 882 | if( !$wgRequest->getInt('reviewform') && $this->limitedUI() ) { |
882 | 883 | return true; |
883 | 884 | } |
| 885 | + # Avoid multi-page diffs that are useless and misbehave (bug 19327) |
| 886 | + if( $this->isMultiPageDiff ) { |
| 887 | + return true; |
| 888 | + } |
884 | 889 | # Check action and if page is protected |
885 | 890 | $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) ) { |
888 | 893 | return true; |
889 | 894 | } |
890 | 895 | # Place the form at the top or bottom as most convenient |
— | — | @@ -1249,18 +1254,34 @@ |
1250 | 1255 | } |
1251 | 1256 | |
1252 | 1257 | /** |
| 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 | + /** |
1253 | 1278 | * Add a link to patrol non-reviewable pages. |
1254 | 1279 | * Also add a diff-to-stable for other pages if possible. |
1255 | 1280 | */ |
1256 | 1281 | public function addDiffLink( $diff, $oldRev, $newRev ) { |
1257 | 1282 | global $wgUser, $wgOut; |
1258 | 1283 | // Is there a stable version? |
1259 | | - if( $oldRev && $this->isReviewable() ) { |
| 1284 | + if( $newRev && $oldRev && $this->isReviewable() ) { |
1260 | 1285 | $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 | | - } |
1265 | 1286 | # Give a link to the diff-to-stable if needed |
1266 | 1287 | if( $frev && !$this->isDiffFromStable ) { |
1267 | 1288 | $article = new Article( $newRev->getTitle() ); |
Index: branches/wmf-deployment/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -1707,6 +1707,7 @@ |
1708 | 1708 | public static function onDiffViewHeader( $diff, $oldRev, $newRev ) { |
1709 | 1709 | self::injectStyleAndJS(); |
1710 | 1710 | $flaggedArticle = FlaggedArticle::getTitleInstance( $diff->getTitle() ); |
| 1711 | + $flaggedArticle->setViewFlags( $diff, $oldRev, $newRev ); |
1711 | 1712 | $flaggedArticle->addDiffLink( $diff, $oldRev, $newRev ); |
1712 | 1713 | $flaggedArticle->addDiffNoticeAndIncludes( $diff, $oldRev, $newRev ); |
1713 | 1714 | return true; |