Merge "Begin 1.27 development cycle"
[lhc/web/wiklou.git] / includes / actions / InfoAction.php
index 5491f81..d9324e7 100644 (file)
@@ -62,13 +62,17 @@ class InfoAction extends FormlessAction {
         *
         * @since 1.22
         * @param Title $title Title to clear cache for
+        * @param int|null $revid Revision id to clear
         */
-       public static function invalidateCache( Title $title ) {
+       public static function invalidateCache( Title $title, $revid = null ) {
                $cache = ObjectCache::getMainWANInstance();
 
-               $revision = Revision::newFromTitle( $title, 0, Revision::READ_LATEST );
-               if ( $revision !== null ) {
-                       $key = wfMemcKey( 'infoaction', sha1( $title->getPrefixedText() ), $revision->getId() );
+               if ( !$revid ) {
+                       $revision = Revision::newFromTitle( $title, 0, Revision::READ_LATEST );
+                       $revid = $revision ? $revision->getId() : null;
+               }
+               if ( $revid !== null ) {
+                       $key = wfMemcKey( 'infoaction', sha1( $title->getPrefixedText() ), $revid );
                        $cache->delete( $key );
                }
        }
@@ -551,9 +555,11 @@ class InfoAction extends FormlessAction {
                );
 
                // Total number of distinct authors
-               $pageInfo['header-edits'][] = array(
-                       $this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageCounts['authors'] )
-               );
+               if ( $pageCounts['authors'] > 0 ) {
+                       $pageInfo['header-edits'][] = array(
+                               $this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageCounts['authors'] )
+                       );
+               }
 
                // Recent number of edits (within past 30 days)
                $pageInfo['header-edits'][] = array(
@@ -714,20 +720,23 @@ class InfoAction extends FormlessAction {
                // Total number of edits
                $edits = (int)$dbr->selectField(
                        'revision',
-                       'COUNT(rev_page)',
+                       'COUNT(*)',
                        array( 'rev_page' => $id ),
                        __METHOD__
                );
                $result['edits'] = $edits;
 
                // Total number of distinct authors
-               $authors = (int)$dbr->selectField(
-                       'revision',
-                       'COUNT(DISTINCT rev_user_text)',
-                       array( 'rev_page' => $id ),
-                       __METHOD__
-               );
-               $result['authors'] = $authors;
+               if ( $config->get( 'MiserMode' ) ) {
+                       $result['authors'] = 0;
+               } else {
+                       $result['authors'] = (int)$dbr->selectField(
+                               'revision',
+                               'COUNT(DISTINCT rev_user_text)',
+                               array( 'rev_page' => $id ),
+                               __METHOD__
+                       );
+               }
 
                // "Recent" threshold defined by RCMaxAge setting
                $threshold = $dbr->timestamp( time() - $config->get( 'RCMaxAge' ) );
@@ -745,7 +754,7 @@ class InfoAction extends FormlessAction {
                $result['recent_edits'] = $edits;
 
                // Recent number of distinct authors
-               $authors = (int)$dbr->selectField(
+               $result['recent_authors'] = (int)$dbr->selectField(
                        'revision',
                        'COUNT(DISTINCT rev_user_text)',
                        array(
@@ -754,7 +763,6 @@ class InfoAction extends FormlessAction {
                        ),
                        __METHOD__
                );
-               $result['recent_authors'] = $authors;
 
                // Subpages (if enabled)
                if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {