Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -813,7 +813,7 @@ |
814 | 814 | */ |
815 | 815 | public static function getRevisionTags( $rev_id ) { |
816 | 816 | $dbr = wfGetDB( DB_SLAVE ); |
817 | | - $tags = $dbr->selectField('flaggedrevs', 'fr_tags', |
| 817 | + $tags = $dbr->selectField( 'flaggedrevs', 'fr_tags', |
818 | 818 | array('fr_rev_id' => $rev_id ), |
819 | 819 | __METHOD__ ); |
820 | 820 | if( !$tags ) |
— | — | @@ -827,8 +827,7 @@ |
828 | 828 | * @return bool, is $title the main page? |
829 | 829 | */ |
830 | 830 | public static function isMainPage( $title ) { |
831 | | - $mp = Title::newMainPage(); |
832 | | - return ( $title->getNamespace()==$mp->getNamespace() && $title->getDBkey()==$mp->getDBkey() ); |
| 831 | + return $title->equals( Title::newMainPage() ); |
833 | 832 | } |
834 | 833 | |
835 | 834 | /** |
— | — | @@ -1134,8 +1133,8 @@ |
1135 | 1134 | array( 'rc_this_oldid' => $rev->getId(), |
1136 | 1135 | 'rc_user_text' => $rev->getRawUserText(), |
1137 | 1136 | 'rc_timestamp' => $dbw->timestamp( $rev->getTimestamp() ) ), |
1138 | | - __METHOD__ |
1139 | | - ); |
| 1137 | + __METHOD__, |
| 1138 | + array( 'LIMIT' => 1 ) ); |
1140 | 1139 | $dbw->commit(); |
1141 | 1140 | |
1142 | 1141 | # Update the article review log |
— | — | @@ -1249,7 +1248,7 @@ |
1250 | 1249 | public static function deleteVisiblitySettings( $article, $user, $reason ) { |
1251 | 1250 | $dbw = wfGetDB( DB_MASTER ); |
1252 | 1251 | $dbw->delete( 'flaggedpage_config', |
1253 | | - array('fpc_page_id' => $article->getID() ), |
| 1252 | + array( 'fpc_page_id' => $article->getID() ), |
1254 | 1253 | __METHOD__ ); |
1255 | 1254 | |
1256 | 1255 | return true; |
— | — | @@ -1610,14 +1609,18 @@ |
1611 | 1610 | * Don't let users vandalize pages by moving them. |
1612 | 1611 | */ |
1613 | 1612 | public static function userCanMove( $title, $user, $action, $result ) { |
1614 | | - global $wgFlaggedArticle; |
| 1613 | + global $wgTitle; |
1615 | 1614 | |
1616 | | - if( $action != 'move' ) |
| 1615 | + if( $action != 'move' || !self::isPageReviewable( $title ) ) |
1617 | 1616 | return true; |
1618 | | - if( !self::isPageReviewable( $title ) ) |
1619 | | - return true; |
1620 | 1617 | # See if there is a stable version |
1621 | | - $frev = $wgFlaggedArticle->getStableRev( true ); |
| 1618 | + if( $wgTitle && $wgTitle->equals( $title ) ) { |
| 1619 | + global $wgFlaggedArticle; |
| 1620 | + // Cache stable version while we are at it. |
| 1621 | + $frev = $wgFlaggedArticle->getStableRev( true ); |
| 1622 | + } else { |
| 1623 | + $frev = self::getStablePageRev( $title ); |
| 1624 | + } |
1622 | 1625 | if( !$frev ) |
1623 | 1626 | return true; |
1624 | 1627 | # Allow for only editors/reviewers to move this |
— | — | @@ -1633,7 +1636,7 @@ |
1634 | 1637 | * Allow users to view reviewed pages. |
1635 | 1638 | */ |
1636 | 1639 | public static function userCanView( $title, $user, $action, $result ) { |
1637 | | - global $wgFlaggedRevsVisible, $wgFlaggedArticle; |
| 1640 | + global $wgFlaggedRevsVisible, $wgTitle; |
1638 | 1641 | # Assume $action may still not be set, in which case, treat it as 'view'... |
1639 | 1642 | if( $action != 'read' ) |
1640 | 1643 | return true; |
— | — | @@ -1644,8 +1647,16 @@ |
1645 | 1648 | return true; |
1646 | 1649 | # See if there is a stable version. Also, see if, given the page |
1647 | 1650 | # config and URL params, the page can be overriden. |
1648 | | - if( $wgFlaggedArticle->pageOverride() && $wgFlaggedArticle->getStableRev() ) { |
1649 | | - $result = true; |
| 1651 | + if( $wgTitle && $wgTitle->equals( $title ) ) { |
| 1652 | + global $wgFlaggedArticle; |
| 1653 | + // Cache stable version while we are at it. |
| 1654 | + if( $wgFlaggedArticle->pageOverride() && $wgFlaggedArticle->getStableRev( true ) ) { |
| 1655 | + $result = true; |
| 1656 | + } |
| 1657 | + } else { |
| 1658 | + if( self::getStablePageRev( $title ) ) { |
| 1659 | + $result = true; |
| 1660 | + } |
1650 | 1661 | } |
1651 | 1662 | return true; |
1652 | 1663 | } |
— | — | @@ -1666,7 +1677,8 @@ |
1667 | 1678 | array( 'rc_this_oldid' => $rev->getID(), |
1668 | 1679 | 'rc_user_text' => $rev->getRawUserText(), |
1669 | 1680 | 'rc_timestamp' => $dbw->timestamp( $rev->getTimestamp() ) ), |
1670 | | - __METHOD__ ); |
| 1681 | + __METHOD__, |
| 1682 | + array( 'USE INDEX' => 'rc_user_text', 'LIMIT' => 1 ) ); |
1671 | 1683 | } |
1672 | 1684 | return true; |
1673 | 1685 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.php |
— | — | @@ -384,7 +384,7 @@ |
385 | 385 | |
386 | 386 | # Some validation vars to make sure nothing changed during |
387 | 387 | $lastTempID = 0; |
388 | | - $lastImgTime = ''; |
| 388 | + $lastImgTime = "0"; |
389 | 389 | |
390 | 390 | # Our template version pointers |
391 | 391 | $tmpset = array(); |
— | — | @@ -632,7 +632,7 @@ |
633 | 633 | 'rc_user_text' => $rev->getRawUserText(), |
634 | 634 | 'rc_timestamp' => $dbw->timestamp( $rev->getTimestamp() ) ), |
635 | 635 | __METHOD__, |
636 | | - array( 'USE INDEX' => 'rc_user_text' ) ); |
| 636 | + array( 'USE INDEX' => 'rc_user_text', 'LIMIT' => 1 ) ); |
637 | 637 | # New page patrol may be enabled. If so, the rc_id may be the first |
638 | 638 | # edit and not this one. If it is different, mark it too. |
639 | 639 | if( $rcid && $rcid != $rev->getId() ) { |