Add feature to disable rollback edit count
authorjan <jan@jans-seite.de>
Wed, 1 Aug 2012 16:52:30 +0000 (18:52 +0200)
committerjan <jan@jans-seite.de>
Thu, 2 Aug 2012 07:12:42 +0000 (09:12 +0200)
This change replaces I85f480726b41871cdf5349a19e3f650285d1dda6 (includes
the change of Catrope).

Add a feature to disable the rollback edit count (change
9bae2198c950040f9f9139893a23a1012d54d8d6) on special pages. Default it
will be disabled on Recentchanges and Watchlist.

Change-Id: Ifbbf802472ce678694b2b3ba4ef441344cc1d572

includes/Linker.php

index ae334c6..26e99cd 100644 (file)
@@ -1673,7 +1673,10 @@ class Linker {
         * @return String: HTML fragment
         */
        public static function buildRollbackLink( $rev, IContextSource $context = null ) {
-               global $wgShowRollbackEditCount;
+               global $wgShowRollbackEditCount, $wgMiserMode;
+               
+               // To config which pages are effected by miser mode
+               $disableRollbackEditCountSpecialPage = array( 'Recentchanges', 'Watchlist' );
 
                if ( $context === null ) {
                        $context = RequestContext::getMain();
@@ -1690,13 +1693,24 @@ class Linker {
                        $query['hidediff'] = '1'; // bug 15999
                }
 
-               if( is_int( $wgShowRollbackEditCount ) && $wgShowRollbackEditCount > 0 ) {
+               $disableRollbackEditCount = false;
+               if( $wgMiserMode ) {
+                       foreach( $disableRollbackEditCountSpecialPage as $specialPage ) {
+                               if( $context->getTitle()->isSpecial( $specialPage ) ) {
+                                       $disableRollbackEditCount = true;
+                                       break;
+                               }
+                       }
+               }
+
+               if( !$disableRollbackEditCount && is_int( $wgShowRollbackEditCount ) && $wgShowRollbackEditCount > 0 ) {
                        $dbr = wfGetDB( DB_SLAVE );
 
                        // Up to the value of $wgShowRollbackEditCount revisions are counted
                        $res = $dbr->select( 'revision',
                                array( 'rev_id', 'rev_user_text' ),
-                               array( 'rev_page' => $rev->getPage() ),
+                               // $rev->getPage() returns null sometimes
+                               array( 'rev_page' => $rev->getTitle()->getArticleID() ),
                                __METHOD__,
                                array(  'USE INDEX' => 'page_timestamp',
                                        'ORDER BY' => 'rev_timestamp DESC',