Only query page_counter if $wgDisableCounters is false
authorReedy <reedy@wikimedia.org>
Tue, 17 Jul 2012 21:16:15 +0000 (22:16 +0100)
committerReedy <reedy@wikimedia.org>
Tue, 17 Jul 2012 21:21:38 +0000 (22:21 +0100)
Change-Id: Ie134090cdd6573d11a7f5510e1d90dab9b06f117

includes/actions/InfoAction.php

index 543beb7..b74996c 100644 (file)
@@ -114,8 +114,8 @@ class InfoAction extends FormlessAction {
                        'watchlist',
                        'COUNT(*)',
                        array(
+                               'wl_namespace' => $title->getNamespace(),
                                'wl_title'     => $title->getDBkey(),
-                               'wl_namespace' => $title->getNamespace()
                        ),
                        __METHOD__
                );
@@ -133,15 +133,20 @@ class InfoAction extends FormlessAction {
                        array( 'rev_page' => $id ),
                        __METHOD__
                );
+               $result = array( 'watchers' => $watchers, 'edits' => $edits,
+                       'authors' => $authors );
 
-               $views = (int)$dbr->selectField(
-                       'page',
-                       'page_counter',
-                       array( 'page_id' => $id ),
-                       __METHOD__
-               );
-
-               return array( 'watchers' => $watchers, 'edits' => $edits,
-                       'authors' => $authors, 'views' => $views );
+               global $wgDisableCounters;
+               if ( !$wgDisableCounters ) {
+                       $views = (int)$dbr->selectField(
+                               'page',
+                               'page_counter',
+                               array( 'page_id' => $id ),
+                               __METHOD__
+                       );
+                       $result['views'] = $views;
+               }
+
+               return $result;
        }
 }