Put InfoAction distinct user counts behind miser mode
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 25 Sep 2015 06:55:16 +0000 (23:55 -0700)
committerOri.livneh <ori@wikimedia.org>
Mon, 28 Sep 2015 17:24:28 +0000 (17:24 +0000)
* The random I/O due to secondary lookups causes timeouts on
  larges pages that keep showing up in the logs.

Change-Id: I9bddcd3ba9ad5ff2f26ccec4553906ecc4a8129b

includes/actions/InfoAction.php

index f3670a8..d9324e7 100644 (file)
@@ -555,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(
@@ -718,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' ) );
@@ -749,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(
@@ -758,7 +763,6 @@ class InfoAction extends FormlessAction {
                        ),
                        __METHOD__
                );
-               $result['recent_authors'] = $authors;
 
                // Subpages (if enabled)
                if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {