r33137 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r33136‎ | r33137 | r33138 >
Date:16:50, 11 April 2008
Author:aaron
Status:old
Tags:
Comment:
*Small fix
*More performance tweaks
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -813,7 +813,7 @@
814814 */
815815 public static function getRevisionTags( $rev_id ) {
816816 $dbr = wfGetDB( DB_SLAVE );
817 - $tags = $dbr->selectField('flaggedrevs', 'fr_tags',
 817+ $tags = $dbr->selectField( 'flaggedrevs', 'fr_tags',
818818 array('fr_rev_id' => $rev_id ),
819819 __METHOD__ );
820820 if( !$tags )
@@ -827,8 +827,7 @@
828828 * @return bool, is $title the main page?
829829 */
830830 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() );
833832 }
834833
835834 /**
@@ -1134,8 +1133,8 @@
11351134 array( 'rc_this_oldid' => $rev->getId(),
11361135 'rc_user_text' => $rev->getRawUserText(),
11371136 'rc_timestamp' => $dbw->timestamp( $rev->getTimestamp() ) ),
1138 - __METHOD__
1139 - );
 1137+ __METHOD__,
 1138+ array( 'LIMIT' => 1 ) );
11401139 $dbw->commit();
11411140
11421141 # Update the article review log
@@ -1249,7 +1248,7 @@
12501249 public static function deleteVisiblitySettings( $article, $user, $reason ) {
12511250 $dbw = wfGetDB( DB_MASTER );
12521251 $dbw->delete( 'flaggedpage_config',
1253 - array('fpc_page_id' => $article->getID() ),
 1252+ array( 'fpc_page_id' => $article->getID() ),
12541253 __METHOD__ );
12551254
12561255 return true;
@@ -1610,14 +1609,18 @@
16111610 * Don't let users vandalize pages by moving them.
16121611 */
16131612 public static function userCanMove( $title, $user, $action, $result ) {
1614 - global $wgFlaggedArticle;
 1613+ global $wgTitle;
16151614
1616 - if( $action != 'move' )
 1615+ if( $action != 'move' || !self::isPageReviewable( $title ) )
16171616 return true;
1618 - if( !self::isPageReviewable( $title ) )
1619 - return true;
16201617 # 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+ }
16221625 if( !$frev )
16231626 return true;
16241627 # Allow for only editors/reviewers to move this
@@ -1633,7 +1636,7 @@
16341637 * Allow users to view reviewed pages.
16351638 */
16361639 public static function userCanView( $title, $user, $action, $result ) {
1637 - global $wgFlaggedRevsVisible, $wgFlaggedArticle;
 1640+ global $wgFlaggedRevsVisible, $wgTitle;
16381641 # Assume $action may still not be set, in which case, treat it as 'view'...
16391642 if( $action != 'read' )
16401643 return true;
@@ -1644,8 +1647,16 @@
16451648 return true;
16461649 # See if there is a stable version. Also, see if, given the page
16471650 # 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+ }
16501661 }
16511662 return true;
16521663 }
@@ -1666,7 +1677,8 @@
16671678 array( 'rc_this_oldid' => $rev->getID(),
16681679 'rc_user_text' => $rev->getRawUserText(),
16691680 'rc_timestamp' => $dbw->timestamp( $rev->getTimestamp() ) ),
1670 - __METHOD__ );
 1681+ __METHOD__,
 1682+ array( 'USE INDEX' => 'rc_user_text', 'LIMIT' => 1 ) );
16711683 }
16721684 return true;
16731685 }
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.php
@@ -384,7 +384,7 @@
385385
386386 # Some validation vars to make sure nothing changed during
387387 $lastTempID = 0;
388 - $lastImgTime = '';
 388+ $lastImgTime = "0";
389389
390390 # Our template version pointers
391391 $tmpset = array();
@@ -632,7 +632,7 @@
633633 'rc_user_text' => $rev->getRawUserText(),
634634 'rc_timestamp' => $dbw->timestamp( $rev->getTimestamp() ) ),
635635 __METHOD__,
636 - array( 'USE INDEX' => 'rc_user_text' ) );
 636+ array( 'USE INDEX' => 'rc_user_text', 'LIMIT' => 1 ) );
637637 # New page patrol may be enabled. If so, the rc_id may be the first
638638 # edit and not this one. If it is different, mark it too.
639639 if( $rcid && $rcid != $rev->getId() ) {

Status & tagging log