Remove hitcounters and associated code
authorChad Horohoe <chadh@wikimedia.org>
Wed, 30 Jul 2014 20:56:20 +0000 (13:56 -0700)
committerChad Horohoe <chadh@wikimedia.org>
Mon, 20 Oct 2014 20:01:55 +0000 (13:01 -0700)
The hitcounter implementation in MediaWiki is flawed
and needs removal. For proper metrics, it is suggested to use
something like Piwik or Google Analytics.

RFC: https://www.mediawiki.org/wiki/Requests_for_comment/Removing_hit_counters_from_MediaWiki_core
Change-Id: I0e5006a7e8a09c800f8fa4effa9399e8afdd7a57

28 files changed:
RELEASE-NOTES-1.25
includes/AutoLoader.php
includes/DefaultSettings.php
includes/MagicWord.php
includes/Setup.php
includes/SiteStats.php
includes/actions/InfoAction.php
includes/api/ApiQueryInfo.php
includes/api/ApiQuerySiteinfo.php
includes/deferred/SiteStatsUpdate.php
includes/deferred/ViewCountUpdate.php [deleted file]
includes/page/WikiPage.php
includes/parser/CoreParserFunctions.php
includes/parser/Parser.php
includes/skins/SkinTemplate.php
includes/specialpage/QueryPage.php
includes/specialpage/SpecialPageFactory.php
includes/specials/SpecialPopularpages.php [deleted file]
includes/specials/SpecialStatistics.php
languages/i18n/en.json
languages/i18n/qqq.json
languages/messages/MessagesEn.php
maintenance/dictionary/mediawiki.dic
maintenance/initSiteStats.php
maintenance/showSiteStats.php
resources/src/mediawiki.legacy/commonPrint.css
tests/parser/parserTest.inc
tests/phpunit/MediaWikiTestCase.php

index 862b132..ee3db43 100644 (file)
@@ -61,6 +61,7 @@ changes to languages because of Bugzilla reports.
 * Deprecated OutputPage::readOnlyPage() and OutputPage::rateLimited().
   Also, the former will now throw an MWException if called with one or more
   arguments.
+* Removed hitcounters and associated code.
 
 == Compatibility ==
 
index 2a45fc3..ab533d2 100644 (file)
@@ -474,7 +474,6 @@ $wgAutoloadLocalClasses = array(
        'SiteStatsUpdate' => 'includes/deferred/SiteStatsUpdate.php',
        'SqlDataUpdate' => 'includes/deferred/SqlDataUpdate.php',
        'SquidUpdate' => 'includes/deferred/SquidUpdate.php',
-       'ViewCountUpdate' => 'includes/deferred/ViewCountUpdate.php',
 
        # includes/diff
        'DiffEngine' => 'includes/diff/DairikiDiff.php',
@@ -1014,7 +1013,6 @@ $wgAutoloadLocalClasses = array(
        'NewFilesPager' => 'includes/specials/SpecialNewimages.php',
        'NewPagesPager' => 'includes/specials/SpecialNewpages.php',
        'PageArchive' => 'includes/specials/SpecialUndelete.php',
-       'PopularPagesPage' => 'includes/specials/SpecialPopularpages.php',
        'ProtectedPagesPager' => 'includes/specials/SpecialProtectedpages.php',
        'ProtectedTitlesPager' => 'includes/specials/SpecialProtectedtitles.php',
        'RandomPage' => 'includes/specials/SpecialRandompage.php',
index f2453e8..d89be1d 100644 (file)
@@ -4115,15 +4115,6 @@ $wgTranscludeCacheExpiry = 3600;
  */
 $wgArticleCountMethod = 'link';
 
-/**
- * wgHitcounterUpdateFreq sets how often page counters should be updated, higher
- * values are easier on the database. A value of 1 causes the counters to be
- * updated on every hit, any higher value n cause them to update *on average*
- * every n hits. Should be set to either 1 or something largish, eg 1000, for
- * maximum efficiency.
- */
-$wgHitcounterUpdateFreq = 1;
-
 /**
  * How many days user must be idle before he is considered inactive. Will affect
  * the number shown on Special:Statistics, Special:ActiveUsers, and the
@@ -5384,12 +5375,6 @@ $wgAggregateStatsID = false;
  */
 $wgStatsFormatString = "stats/%s - %s 1 1 1 1 %s\n";
 
-/**
- * Whereas to count the number of time an article is viewed.
- * Does not work if pages are cached (for example with squid).
- */
-$wgDisableCounters = false;
-
 /**
  * InfoAction retrieves a list of transclusion links (both to and from).
  * This number puts a limit on that query in the case of highly transcluded
index 4d17298..d281555 100644 (file)
@@ -172,7 +172,6 @@ class MagicWord {
                'directionmark',
                'contentlanguage',
                'numberofadmins',
-               'numberofviews',
                'cascadingsources',
        );
 
@@ -215,7 +214,6 @@ class MagicWord {
                'localtimestamp' => 3600,
                'pagesinnamespace' => 3600,
                'numberofadmins' => 3600,
-               'numberofviews' => 3600,
                'numberingroup' => 3600,
        );
 
index 743936e..2faf196 100644 (file)
@@ -517,6 +517,10 @@ if ( $wgTmpDirectory === false ) {
        wfProfileOut( $fname . '-tempDir' );
 }
 
+// We don't use counters anymore. Left here for extensions still
+// expecting this to exist. Should be removed sometime 1.26 or later.
+$wgDisableCounters = true;
+
 wfProfileOut( $fname . '-defaults2' );
 wfProfileIn( $fname . '-misc1' );
 
index 3dc1793..32c6761 100644 (file)
@@ -102,7 +102,6 @@ class SiteStats {
        static function doLoad( $db ) {
                return $db->selectRow( 'site_stats', array(
                                'ss_row_id',
-                               'ss_total_views',
                                'ss_total_edits',
                                'ss_good_articles',
                                'ss_total_pages',
@@ -113,11 +112,16 @@ class SiteStats {
        }
 
        /**
+        * Return the total number of page views. Except we don't track those anymore.
+        * Stop calling this function, it will be removed some time in the future. It's
+        * kept here simply to prevent fatal errors.
+        *
+        * @deprecated since 1.25
         * @return int
         */
        static function views() {
-               self::load();
-               return self::$row->ss_total_views;
+               wfDeprecated( __METHOD__, '1.25' );
+               return 0;
        }
 
        /**
@@ -249,7 +253,6 @@ class SiteStats {
                }
                // Now check for underflow/overflow
                foreach ( array(
-                       'ss_total_views',
                        'ss_total_edits',
                        'ss_good_articles',
                        'ss_total_pages',
@@ -274,7 +277,7 @@ class SiteStatsInit {
 
        // Various stats
        private $mEdits = null, $mArticles = null, $mPages = null;
-       private $mUsers = null, $mViews = null, $mFiles = null;
+       private $mUsers = null, $mFiles = null;
 
        /**
         * Constructor
@@ -348,15 +351,6 @@ class SiteStatsInit {
                return $this->mUsers;
        }
 
-       /**
-        * Count views
-        * @return int
-        */
-       public function views() {
-               $this->mViews = $this->db->selectField( 'page', 'SUM(page_counter)', '', __METHOD__ );
-               return $this->mViews;
-       }
-
        /**
         * Count total files
         * @return int
@@ -374,11 +368,10 @@ class SiteStatsInit {
         * - Boolean: whether to use the master DB
         * - DatabaseBase: database connection to use
         * @param array $options Array of options, may contain the following values
-        * - views Boolean: when true, do not update the number of page views (default: true)
         * - activeUsers Boolean: whether to update the number of active users (default: false)
         */
        public static function doAllAndCommit( $database, array $options = array() ) {
-               $options += array( 'update' => false, 'views' => true, 'activeUsers' => false );
+               $options += array( 'update' => false, 'activeUsers' => false );
 
                // Grab the object and count everything
                $counter = new SiteStatsInit( $database );
@@ -389,11 +382,6 @@ class SiteStatsInit {
                $counter->users();
                $counter->files();
 
-               // Only do views if we don't want to not count them
-               if ( $options['views'] ) {
-                       $counter->views();
-               }
-
                $counter->refresh();
 
                // Count active users if need be
@@ -403,8 +391,7 @@ class SiteStatsInit {
        }
 
        /**
-        * Refresh site_stats. If you want ss_total_views to be updated, be sure to
-        * call views() first.
+        * Refresh site_stats
         */
        public function refresh() {
                $values = array(
@@ -414,8 +401,6 @@ class SiteStatsInit {
                        'ss_total_pages' => ( $this->mPages === null ? $this->pages() : $this->mPages ),
                        'ss_users' => ( $this->mUsers === null ? $this->users() : $this->mUsers ),
                        'ss_images' => ( $this->mFiles === null ? $this->files() : $this->mFiles ),
-               ) + (
-                       $this->mViews ? array( 'ss_total_views' => $this->mViews ) : array()
                );
 
                $dbw = wfGetDB( DB_MASTER );
index f932a40..12e845b 100644 (file)
@@ -314,13 +314,6 @@ class InfoAction extends FormlessAction {
                        $this->msg( 'pageinfo-robot-policy' ), $this->msg( "pageinfo-robot-${policy['index']}" )
                );
 
-               if ( isset( $pageCounts['views'] ) ) {
-                       // Number of views
-                       $pageInfo['header-basic'][] = array(
-                               $this->msg( 'pageinfo-views' ), $lang->formatNum( $pageCounts['views'] )
-                       );
-               }
-
                $unwatchedPageThreshold = $config->get( 'UnwatchedPageThreshold' );
                if (
                        $user->isAllowed( 'unwatchedpages' ) ||
@@ -644,17 +637,6 @@ class InfoAction extends FormlessAction {
                $dbr = wfGetDB( DB_SLAVE );
                $result = array();
 
-               if ( !$config->get( 'DisableCounters' ) ) {
-                       // Number of views
-                       $views = (int)$dbr->selectField(
-                               'page',
-                               'page_counter',
-                               array( 'page_id' => $id ),
-                               __METHOD__
-                       );
-                       $result['views'] = $views;
-               }
-
                // Number of page watchers
                $watchers = (int)$dbr->selectField(
                        'watchlist',
index d7037e3..0c93507 100644 (file)
@@ -64,9 +64,6 @@ class ApiQueryInfo extends ApiQueryBase {
                }
                $pageSet->requestField( 'page_is_new' );
                $config = $this->getConfig();
-               if ( !$config->get( 'DisableCounters' ) ) {
-                       $pageSet->requestField( 'page_counter' );
-               }
                $pageSet->requestField( 'page_touched' );
                $pageSet->requestField( 'page_latest' );
                $pageSet->requestField( 'page_len' );
@@ -328,9 +325,6 @@ class ApiQueryInfo extends ApiQueryBase {
                        : array();
                $this->pageIsNew = $pageSet->getCustomField( 'page_is_new' );
 
-               if ( !$this->getConfig()->get( 'DisableCounters' ) ) {
-                       $this->pageCounter = $pageSet->getCustomField( 'page_counter' );
-               }
                $this->pageTouched = $pageSet->getCustomField( 'page_touched' );
                $this->pageLatest = $pageSet->getCustomField( 'page_latest' );
                $this->pageLength = $pageSet->getCustomField( 'page_len' );
@@ -392,9 +386,6 @@ class ApiQueryInfo extends ApiQueryBase {
                if ( $titleExists ) {
                        $pageInfo['touched'] = wfTimestamp( TS_ISO_8601, $this->pageTouched[$pageid] );
                        $pageInfo['lastrevid'] = intval( $this->pageLatest[$pageid] );
-                       $pageInfo['counter'] = $this->getConfig()->get( 'DisableCounters' )
-                               ? ''
-                               : intval( $this->pageCounter[$pageid] );
                        $pageInfo['length'] = intval( $this->pageLength[$pageid] );
 
                        if ( isset( $this->pageIsRedir[$pageid] ) && $this->pageIsRedir[$pageid] ) {
index 311438f..feb869e 100644 (file)
@@ -481,9 +481,6 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $data = array();
                $data['pages'] = intval( SiteStats::pages() );
                $data['articles'] = intval( SiteStats::articles() );
-               if ( !$this->getConfig()->get( 'DisableCounters' ) ) {
-                       $data['views'] = intval( SiteStats::views() );
-               }
                $data['edits'] = intval( SiteStats::edits() );
                $data['images'] = intval( SiteStats::images() );
                $data['users'] = intval( SiteStats::users() );
index 7bfafee..97a17c3 100644 (file)
@@ -22,9 +22,6 @@
  * Class for handling updates to the site_stats table
  */
 class SiteStatsUpdate implements DeferrableUpdate {
-       /** @var int */
-       protected $views = 0;
-
        /** @var int */
        protected $edits = 0;
 
@@ -42,7 +39,6 @@ class SiteStatsUpdate implements DeferrableUpdate {
 
        // @todo deprecate this constructor
        function __construct( $views, $edits, $good, $pages = 0, $users = 0 ) {
-               $this->views = $views;
                $this->edits = $edits;
                $this->articles = $good;
                $this->pages = $pages;
@@ -100,7 +96,6 @@ class SiteStatsUpdate implements DeferrableUpdate {
                        }
                        $pd = $this->getPendingDeltas();
                        // Piggy-back the async deltas onto those of this stats update....
-                       $this->views += ( $pd['ss_total_views']['+'] - $pd['ss_total_views']['-'] );
                        $this->edits += ( $pd['ss_total_edits']['+'] - $pd['ss_total_edits']['-'] );
                        $this->articles += ( $pd['ss_good_articles']['+'] - $pd['ss_good_articles']['-'] );
                        $this->pages += ( $pd['ss_total_pages']['+'] - $pd['ss_total_pages']['-'] );
@@ -110,7 +105,6 @@ class SiteStatsUpdate implements DeferrableUpdate {
 
                // Build up an SQL query of deltas and apply them...
                $updates = '';
-               $this->appendUpdate( $updates, 'ss_total_views', $this->views );
                $this->appendUpdate( $updates, 'ss_total_edits', $this->edits );
                $this->appendUpdate( $updates, 'ss_good_articles', $this->articles );
                $this->appendUpdate( $updates, 'ss_total_pages', $this->pages );
@@ -160,7 +154,6 @@ class SiteStatsUpdate implements DeferrableUpdate {
        }
 
        protected function doUpdatePendingDeltas() {
-               $this->adjustPending( 'ss_total_views', $this->views );
                $this->adjustPending( 'ss_total_edits', $this->edits );
                $this->adjustPending( 'ss_good_articles', $this->articles );
                $this->adjustPending( 'ss_total_pages', $this->pages );
@@ -226,7 +219,7 @@ class SiteStatsUpdate implements DeferrableUpdate {
                global $wgMemc;
 
                $pending = array();
-               foreach ( array( 'ss_total_views', 'ss_total_edits',
+               foreach ( array( 'ss_total_edits',
                        'ss_good_articles', 'ss_total_pages', 'ss_users', 'ss_images' ) as $type
                ) {
                        // Get pending increments and pending decrements
diff --git a/includes/deferred/ViewCountUpdate.php b/includes/deferred/ViewCountUpdate.php
deleted file mode 100644 (file)
index 8282295..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-<?php
-/**
- * Update for the 'page_counter' field
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
-
-/**
- * Update for the 'page_counter' field, when $wgDisableCounters is false.
- *
- * Depending on $wgHitcounterUpdateFreq, this will directly increment the
- * 'page_counter' field or use the 'hitcounter' table and then collect the data
- * from that table to update the 'page_counter' field in a batch operation.
- */
-class ViewCountUpdate implements DeferrableUpdate {
-       /** @var int Page ID to increment the view count */
-       protected $id;
-
-       /**
-        * Constructor
-        *
-        * @param int $id Page ID to increment the view count
-        */
-       public function __construct( $id ) {
-               $this->id = intval( $id );
-       }
-
-       /**
-        * Run the update
-        */
-       public function doUpdate() {
-               global $wgHitcounterUpdateFreq;
-
-               $dbw = wfGetDB( DB_MASTER );
-
-               if ( $wgHitcounterUpdateFreq <= 1 || $dbw->getType() == 'sqlite' ) {
-                       $id = $this->id;
-                       $method = __METHOD__;
-                       $dbw->onTransactionIdle( function () use ( $dbw, $id, $method ) {
-                               try {
-                                       $dbw->update( 'page',
-                                               array( 'page_counter = page_counter + 1' ),
-                                               array( 'page_id' => $id ),
-                                               $method
-                                       );
-                               } catch ( DBError $e ) {
-                                       MWExceptionHandler::logException( $e );
-                               }
-                       } );
-                       return;
-               }
-
-               # Not important enough to warrant an error page in case of failure
-               try {
-                       // Since `hitcounter` is non-transactional, the contention is minimal
-                       $dbw->insert( 'hitcounter', array( 'hc_id' => $this->id ), __METHOD__ );
-                       $checkfreq = intval( $wgHitcounterUpdateFreq / 25 + 1 );
-                       if ( rand() % $checkfreq == 0 && $dbw->lastErrno() == 0 ) {
-                               $this->collect();
-                       }
-               } catch ( DBError $e ) {
-                       MWExceptionHandler::logException( $e );
-               }
-       }
-
-       protected function collect() {
-               global $wgHitcounterUpdateFreq;
-
-               $dbw = wfGetDB( DB_MASTER );
-
-               $rown = $dbw->selectField( 'hitcounter', 'COUNT(*)', array(), __METHOD__ );
-               if ( $rown < $wgHitcounterUpdateFreq ) {
-                       return;
-               }
-
-               wfProfileIn( __METHOD__ . '-collect' );
-               $old_user_abort = ignore_user_abort( true );
-
-               $dbType = $dbw->getType();
-               $tabletype = $dbType == 'mysql' ? "ENGINE=HEAP " : '';
-               $hitcounterTable = $dbw->tableName( 'hitcounter' );
-               $acchitsTable = $dbw->tableName( 'acchits' );
-               $pageTable = $dbw->tableName( 'page' );
-
-               $dbw->lockTables( array(), array( 'hitcounter' ), __METHOD__, false );
-               $dbw->query( "CREATE TEMPORARY TABLE $acchitsTable $tabletype AS " .
-                       "SELECT hc_id,COUNT(*) AS hc_n FROM $hitcounterTable " .
-                       'GROUP BY hc_id', __METHOD__ );
-               $dbw->delete( 'hitcounter', '*', __METHOD__ );
-               $dbw->unlockTables( __METHOD__ );
-
-               if ( $dbType == 'mysql' ) {
-                       $dbw->query( "UPDATE $pageTable,$acchitsTable SET page_counter=page_counter + hc_n " .
-                               'WHERE page_id = hc_id', __METHOD__ );
-               } else {
-                       $dbw->query( "UPDATE $pageTable SET page_counter=page_counter + hc_n " .
-                               "FROM $acchitsTable WHERE page_id = hc_id", __METHOD__ );
-               }
-               $dbw->query( "DROP TABLE $acchitsTable", __METHOD__ );
-
-               ignore_user_abort( $old_user_abort );
-               wfProfileOut( __METHOD__ . '-collect' );
-       }
-}
index 9ade16e..81c93a1 100644 (file)
@@ -88,11 +88,6 @@ class WikiPage implements Page, IDBAccessObject {
         */
        protected $mLinksUpdated = '19700101000000';
 
-       /**
-        * @var int|null
-        */
-       protected $mCounter = null;
-
        /**
         * Constructor and clear the article
         * @param Title $title Reference to a Title object.
@@ -247,7 +242,6 @@ class WikiPage implements Page, IDBAccessObject {
         */
        protected function clearCacheFields() {
                $this->mId = null;
-               $this->mCounter = null;
                $this->mRedirectTarget = null; // Title object if set
                $this->mLastRevision = null; // Latest revision
                $this->mTouched = '19700101000000';
@@ -419,7 +413,6 @@ class WikiPage implements Page, IDBAccessObject {
                        $this->mTitle->loadRestrictions( $data->page_restrictions );
 
                        $this->mId = intval( $data->page_id );
-                       $this->mCounter = intval( $data->page_counter );
                        $this->mTouched = wfTimestamp( TS_MW, $data->page_touched );
                        $this->mLinksUpdated = wfTimestampOrNull( TS_MW, $data->page_links_updated );
                        $this->mIsRedirect = intval( $data->page_is_redirect );
@@ -476,17 +469,6 @@ class WikiPage implements Page, IDBAccessObject {
                return $this->exists() || $this->mTitle->isAlwaysKnown();
        }
 
-       /**
-        * @return int The view count for the page
-        */
-       public function getCount() {
-               if ( !$this->mDataLoaded ) {
-                       $this->loadPageData();
-               }
-
-               return $this->mCounter;
-       }
-
        /**
         * Tests if the article content represents a redirect
         *
@@ -1183,17 +1165,10 @@ class WikiPage implements Page, IDBAccessObject {
         * @param int $oldid The revision id being viewed. If not given or 0, latest revision is assumed.
         */
        public function doViewUpdates( User $user, $oldid = 0 ) {
-               global $wgDisableCounters;
                if ( wfReadOnly() ) {
                        return;
                }
 
-               // Don't update page view counters on views from bot users (bug 14044)
-               if ( !$wgDisableCounters && !$user->isAllowed( 'bot' ) && $this->exists() ) {
-                       DeferredUpdates::addUpdate( new ViewCountUpdate( $this->getId() ) );
-                       DeferredUpdates::addUpdate( new SiteStatsUpdate( 1, 0, 0 ) );
-               }
-
                // Update newtalk / watchlist notification status
                $user->clearNotification( $this->mTitle, $oldid );
        }
@@ -1262,7 +1237,6 @@ class WikiPage implements Page, IDBAccessObject {
                        'page_id'           => $page_id,
                        'page_namespace'    => $this->mTitle->getNamespace(),
                        'page_title'        => $this->mTitle->getDBkey(),
-                       'page_counter'      => 0,
                        'page_restrictions' => '',
                        'page_is_redirect'  => 0, // Will set this shortly...
                        'page_is_new'       => 1,
index 355a3c1..8828826 100644 (file)
@@ -44,7 +44,7 @@ class CoreParserFunctions {
                        'canonicalurle', 'formatnum', 'grammar', 'gender', 'plural',
                        'numberofpages', 'numberofusers', 'numberofactiveusers',
                        'numberofarticles', 'numberoffiles', 'numberofadmins',
-                       'numberingroup', 'numberofedits', 'numberofviews', 'language',
+                       'numberingroup', 'numberofedits', 'language',
                        'padleft', 'padright', 'anchorencode', 'defaultsort', 'filepath',
                        'pagesincategory', 'pagesize', 'protectionlevel',
                        'namespacee', 'namespacenumber', 'talkspace', 'talkspacee',
@@ -489,10 +489,6 @@ class CoreParserFunctions {
        public static function numberofedits( $parser, $raw = null ) {
                return self::formatRaw( SiteStats::edits(), $raw );
        }
-       public static function numberofviews( $parser, $raw = null ) {
-               global $wgDisableCounters;
-               return !$wgDisableCounters ? self::formatRaw( SiteStats::views(), $raw ) : '';
-       }
        public static function pagesinnamespace( $parser, $namespace = 0, $raw = null ) {
                return self::formatRaw( SiteStats::pagesInNs( intval( $namespace ) ), $raw );
        }
index ddd1f9a..e6478a4 100644 (file)
@@ -3155,10 +3155,6 @@ class Parser {
                        case 'numberofedits':
                                $value = $pageLang->formatNum( SiteStats::edits() );
                                break;
-                       case 'numberofviews':
-                               global $wgDisableCounters;
-                               $value = !$wgDisableCounters ? $pageLang->formatNum( SiteStats::views() ) : '';
-                               break;
                        case 'currenttimestamp':
                                $value = wfTimestamp( TS_MW, $ts );
                                break;
index c1db302..7ef3a8f 100644 (file)
@@ -260,7 +260,7 @@ class SkinTemplate extends Skin {
         */
        protected function prepareQuickTemplate() {
                global $wgContLang, $wgScript, $wgStylePath, $wgMimeType, $wgJsMimeType,
-                       $wgDisableCounters, $wgSitename, $wgLogo, $wgMaxCredits,
+                       $wgSitename, $wgLogo, $wgMaxCredits,
                        $wgShowCreditsIfMax, $wgArticlePath,
                        $wgScriptPath, $wgServer;
 
@@ -373,19 +373,13 @@ class SkinTemplate extends Skin {
                $tpl->set( 'logo', $this->logoText() );
 
                $tpl->set( 'copyright', false );
+               // No longer used
                $tpl->set( 'viewcount', false );
                $tpl->set( 'lastmod', false );
                $tpl->set( 'credits', false );
                $tpl->set( 'numberofwatchingusers', false );
                if ( $out->isArticle() && $title->exists() ) {
                        if ( $this->isRevisionCurrent() ) {
-                               if ( !$wgDisableCounters ) {
-                                       $viewcount = $this->getWikiPage()->getCount();
-                                       if ( $viewcount ) {
-                                               $tpl->set( 'viewcount', $this->msg( 'viewcount' )->numParams( $viewcount )->parse() );
-                                       }
-                               }
-
                                if ( $wgMaxCredits != 0 ) {
                                        $tpl->set( 'credits', Action::factory( 'credits', $this->getWikiPage(),
                                                $this->getContext() )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
@@ -407,7 +401,6 @@ class SkinTemplate extends Skin {
                $tpl->set( 'footerlinks', array(
                        'info' => array(
                                'lastmod',
-                               'viewcount',
                                'numberofwatchingusers',
                                'credits',
                                'copyright',
index b229e06..167135b 100644 (file)
@@ -60,7 +60,6 @@ abstract class QueryPage extends SpecialPage {
         * @return array
         */
        public static function getPages() {
-               global $wgDisableCounters;
                static $qp = null;
 
                if ( $qp === null ) {
@@ -102,10 +101,6 @@ abstract class QueryPage extends SpecialPage {
                                array( 'WithoutInterwikiPage', 'Withoutinterwiki' ),
                        );
                        wfRunHooks( 'wgQueryPages', array( &$qp ) );
-
-                       if ( !$wgDisableCounters ) {
-                               $qp[] = array( 'PopularPagesPage', 'Popularpages' );
-                       }
                }
 
                return $qp;
index 9a6b787..cba4d13 100644 (file)
@@ -214,7 +214,7 @@ class SpecialPageFactory {
         */
        private static function getPageList() {
                global $wgSpecialPages;
-               global $wgDisableCounters, $wgDisableInternalSearch, $wgEmailAuthentication;
+               global $wgDisableInternalSearch, $wgEmailAuthentication;
                global $wgEnableEmail, $wgEnableJavaScriptTest;
                global $wgPageLanguageUseDB;
 
@@ -223,10 +223,6 @@ class SpecialPageFactory {
 
                        self::$list = self::$coreList;
 
-                       if ( !$wgDisableCounters ) {
-                               self::$list['Popularpages'] = 'PopularPagesPage';
-                       }
-
                        if ( !$wgDisableInternalSearch ) {
                                self::$list['Search'] = 'SpecialSearch';
                        }
diff --git a/includes/specials/SpecialPopularpages.php b/includes/specials/SpecialPopularpages.php
deleted file mode 100644 (file)
index 2a80f65..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-/**
- * Implements Special:PopularPages
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup SpecialPage
- */
-
-/**
- * A special page that list most viewed pages
- *
- * @ingroup SpecialPage
- */
-class PopularPagesPage extends QueryPage {
-       function __construct( $name = 'Popularpages' ) {
-               parent::__construct( $name );
-       }
-
-       function isExpensive() {
-               # page_counter is not indexed
-               return true;
-       }
-
-       function isSyndicated() {
-               return false;
-       }
-
-       function getQueryInfo() {
-               return array(
-                       'tables' => array( 'page' ),
-                       'fields' => array(
-                               'namespace' => 'page_namespace',
-                               'title' => 'page_title',
-                               'value' => 'page_counter' ),
-                       'conds' => array(
-                               'page_is_redirect' => 0,
-                               'page_namespace' => MWNamespace::getContentNamespaces()
-                       )
-               );
-       }
-
-       /**
-        * @param Skin $skin
-        * @param object $result Result row
-        * @return string
-        */
-       function formatResult( $skin, $result ) {
-               global $wgContLang;
-
-               $title = Title::makeTitleSafe( $result->namespace, $result->title );
-               if ( !$title ) {
-                       return Html::element(
-                               'span',
-                               array( 'class' => 'mw-invalidtitle' ),
-                               Linker::getInvalidTitleDescription(
-                                       $this->getContext(),
-                                       $result->namespace,
-                                       $result->title )
-                       );
-               }
-
-               $link = Linker::linkKnown(
-                       $title,
-                       htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) )
-               );
-               $nv = $this->msg( 'nviews' )->numParams( $result->value )->escaped();
-
-               return $this->getLanguage()->specialList( $link, $nv );
-       }
-
-       protected function getGroupName() {
-               return 'wiki';
-       }
-}
index f0e360e..1bbc2f3 100644 (file)
@@ -28,7 +28,7 @@
  * @ingroup SpecialPage
  */
 class SpecialStatistics extends SpecialPage {
-       private $views, $edits, $good, $images, $total, $users,
+       private $edits, $good, $images, $total, $users,
                $activeUsers = 0;
 
        public function __construct() {
@@ -38,13 +38,11 @@ class SpecialStatistics extends SpecialPage {
        public function execute( $par ) {
                global $wgMemc;
 
-               $disableCounters = $this->getConfig()->get( 'DisableCounters' );
                $miserMode = $this->getConfig()->get( 'MiserMode' );
 
                $this->setHeaders();
                $this->getOutput()->addModuleStyles( 'mediawiki.special' );
 
-               $this->views = SiteStats::views();
                $this->edits = SiteStats::edits();
                $this->good = SiteStats::articles();
                $this->images = SiteStats::images();
@@ -53,12 +51,6 @@ class SpecialStatistics extends SpecialPage {
                $this->activeUsers = SiteStats::activeUsers();
                $this->hook = '';
 
-               # Staticic - views
-               $viewsStats = '';
-               if ( !$disableCounters ) {
-                       $viewsStats = $this->getViewsStats();
-               }
-
                # Set active user count
                if ( !$miserMode ) {
                        $key = wfMemcKey( 'sitestats', 'activeusers-updated' );
@@ -83,12 +75,6 @@ class SpecialStatistics extends SpecialPage {
 
                # Statistic - usergroups
                $text .= $this->getGroupStats();
-               $text .= $viewsStats;
-
-               # Statistic - popular pages
-               if ( !$disableCounters && !$miserMode ) {
-                       $text .= $this->getMostViewedPages();
-               }
 
                # Statistic - other
                $extraStats = array();
@@ -237,63 +223,6 @@ class SpecialStatistics extends SpecialPage {
                return $text;
        }
 
-       private function getViewsStats() {
-               return Xml::openElement( 'tr' ) .
-                       Xml::tags( 'th', array( 'colspan' => '2' ), $this->msg( 'statistics-header-views' )->parse() ) .
-                       Xml::closeElement( 'tr' ) .
-                               $this->formatRow( $this->msg( 'statistics-views-total' )->parse(),
-                                       $this->getLanguage()->formatNum( $this->views ),
-                                               array( 'class' => 'mw-statistics-views-total' ), 'statistics-views-total-desc' ) .
-                               $this->formatRow( $this->msg( 'statistics-views-peredit' )->parse(),
-                                       $this->getLanguage()->formatNum( sprintf( '%.2f', $this->edits ?
-                                               $this->views / $this->edits : 0 ) ),
-                                               array( 'class' => 'mw-statistics-views-peredit' ) );
-       }
-
-       private function getMostViewedPages() {
-               $text = '';
-               $dbr = wfGetDB( DB_SLAVE );
-               $res = $dbr->select(
-                       'page',
-                       array(
-                               'page_namespace',
-                               'page_title',
-                               'page_counter',
-                       ),
-                       array(
-                               'page_is_redirect' => 0,
-                               'page_counter > 0',
-                       ),
-                       __METHOD__,
-                       array(
-                               'ORDER BY' => 'page_counter DESC',
-                               'LIMIT' => 10,
-                       )
-               );
-
-               if ( $res->numRows() > 0 ) {
-                       $text .= Xml::openElement( 'tr' );
-                       $text .= Xml::tags(
-                               'th',
-                               array( 'colspan' => '2' ),
-                               $this->msg( 'statistics-mostpopular' )->parse()
-                       );
-                       $text .= Xml::closeElement( 'tr' );
-
-                       foreach ( $res as $row ) {
-                               $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
-
-                               if ( $title instanceof Title ) {
-                                       $text .= $this->formatRow( Linker::link( $title ),
-                                               $this->getLanguage()->formatNum( $row->page_counter ) );
-                               }
-                       }
-                       $res->free();
-               }
-
-               return $text;
-       }
-
        /**
         * Conversion of external statistics into an internal representation
         * Following a ([<header-message>][<item-message>] = number) pattern
index fc47178..ab44ca2 100644 (file)
        "statistics-summary": "",
        "statistics-header-pages": "Page statistics",
        "statistics-header-edits": "Edit statistics",
-       "statistics-header-views": "View statistics",
        "statistics-header-users": "User statistics",
        "statistics-header-hooks": "Other statistics",
        "statistics-articles": "Content pages",
        "statistics-files": "Uploaded files",
        "statistics-edits": "Page edits since {{SITENAME}} was set up",
        "statistics-edits-average": "Average edits per page",
-       "statistics-views-total": "Views total",
-       "statistics-views-total-desc": "Views to non-existing pages and special pages are not included",
-       "statistics-views-peredit": "Views per edit",
        "statistics-users": "Registered [[Special:ListUsers|users]]",
        "statistics-users-active": "Active users",
        "statistics-users-active-desc": "Users who have performed an action in the last {{PLURAL:$1|day|$1 days}}",
-       "statistics-mostpopular": "Most viewed pages",
        "statistics-footer": "",
        "pageswithprop": "Pages with a page property",
        "pageswithprop-summary": "",
        "unusedcategories-summary": "",
        "unusedimages": "Unused files",
        "unusedimages-summary": "",
-       "popularpages": "Popular pages",
-       "popularpages-summary": "",
        "wantedcategories": "Wanted categories",
        "wantedcategories-summary": "",
        "wantedpages": "Wanted pages",
        "pageinfo-robot-policy": "Indexing by robots",
        "pageinfo-robot-index": "Allowed",
        "pageinfo-robot-noindex": "Disallowed",
-       "pageinfo-views": "Number of views",
        "pageinfo-watchers": "Number of page watchers",
        "pageinfo-few-watchers": "Fewer than $1 {{PLURAL:$1|watcher|watchers}}",
        "pageinfo-redirects-name": "Number of redirects to this page",
index 20d0618..a6f0fa6 100644 (file)
        "statistics-summary": "{{doc-specialpagesummary|statistics}}",
        "statistics-header-pages": "Used in [[Special:Statistics]]",
        "statistics-header-edits": "Used in [[Special:Statistics]]",
-       "statistics-header-views": "Used in [[Special:Statistics]]",
        "statistics-header-users": "Used in [[Special:Statistics]].\n{{Identical|User statistics}}",
        "statistics-header-hooks": "Header of a section on [[Special:Statistics]] containing data provided by MediaWiki extensions",
        "statistics-articles": "Used in [[Special:Statistics]].\n\nA 'content page' is a page that forms part of the purpose of the wiki. It includes the main page and pages in the main namespace and any other namespaces that are included when the wiki is customised. For example on Wikimedia Commons 'content pages' include pages in the file and category namespaces. On Wikinews 'content pages' include pages in the Portal namespace. For technical definition of 'content namespaces' see [[mw:Manual:Using_custom_namespaces#Content_namespaces|MediaWiki]].\n\nPossible alternatives to the word 'content' are 'subject matter' or 'wiki subject' or 'wiki purpose'.\n\n{{Identical|Content page}}",
        "statistics-files": "Used in [[Special:Statistics]].\n{{Identical|Uploaded file}}",
        "statistics-edits": "Used in [[Special:Statistics]]",
        "statistics-edits-average": "Used in [[Special:Statistics]]",
-       "statistics-views-total": "Used in [[Special:Statistics]]",
-       "statistics-views-total-desc": "This message follows the message {{msg-mw|statistics-views-total}}, in [[Special:Statistics]].",
-       "statistics-views-peredit": "Used in [[Special:Statistics]]",
        "statistics-users": "{{doc-important|Do not translate \"Special:ListUsers\"}}\nUsed in [[Special:Statistics]].",
        "statistics-users-active": "Used in [[Special:Statistics]]",
        "statistics-users-active-desc": "Description shown beneath ''Active users'' in [[Special:Statistics]]. Parameters:\n* $1 - Value of <code>$wgRCMaxAge</code> in days",
-       "statistics-mostpopular": "Used in [[Special:Statistics]]",
        "statistics-footer": "{{notranslate}}",
        "pageswithprop": "{{doc-special|PagesWithProp}}\n{{Identical|Page with page property}}",
        "pageswithprop-summary": "{{doc-specialpagesummary|pageswithprop}}",
        "unusedcategories-summary": "{{doc-specialpagesummary|unusedcategories}}",
        "unusedimages": "{{doc-special|UnusedImages}}",
        "unusedimages-summary": "{{doc-specialpagesummary|unusedimages}}",
-       "popularpages": "{{doc-special|PopularPages}}",
-       "popularpages-summary": "{{doc-specialpagesummary|popularpages}}",
        "wantedcategories": "{{doc-special|WantedCategories}}",
        "wantedcategories-summary": "{{doc-specialpagesummary|wantedcategories}}",
        "wantedpages": "{{doc-special|WantedPages}}\n{{Identical|Wanted page}}",
        "pageinfo-robot-policy": "The search engine status of the page.\n\nUsed as label. Followed by any one of the following messages:\n*{{msg-mw|Pageinfo-robot-index}}\n*{{msg-mw|Pageinfo-robot-noindex}}",
        "pageinfo-robot-index": "An indication that the page is indexable by search engines, that is listed in their search results.\n\nPreceded by the label {{msg-mw|Pageinfo-robot-policy}}.",
        "pageinfo-robot-noindex": "An indication that the page is not indexable (that is, is not listed on the results page of a search engine).\n\nPreceded by the label {{msg-mw|Pageinfo-robot-policy}}.",
-       "pageinfo-views": "The number of times the page has been viewed.",
        "pageinfo-watchers": "Header of the row in the first table of the info action.",
        "pageinfo-few-watchers": "Message displayed when there are fewer than $wgUnwatchedPageThreshold watchers. $1 is the value of $wgUnwatchedPageThreshold.",
        "pageinfo-redirects-name": "Header of the row in the first table of the info action.\n\nFollowed by {{msg-mw|Pageinfo-redirects-value}}.\n\nUsed as link text. The link points to \"{{int:Whatlinkshere-title}}\" page ([[Special:WhatLinksHere]]).\n\nSee example: [{{canonicalurl:Main page|action=info}} Main page?action=info]",
index 0a10279..f1238b6 100644 (file)
@@ -240,7 +240,6 @@ $magicWords = array(
        'numberofusers'           => array( 1, 'NUMBEROFUSERS' ),
        'numberofactiveusers'     => array( 1, 'NUMBEROFACTIVEUSERS' ),
        'numberofedits'           => array( 1, 'NUMBEROFEDITS' ),
-       'numberofviews'           => array( 1, 'NUMBEROFVIEWS' ),
        'pagename'                => array( 1, 'PAGENAME' ),
        'pagenamee'               => array( 1, 'PAGENAMEE' ),
        'namespace'               => array( 1, 'NAMESPACE' ),
index 99f43ff..ad8b004 100644 (file)
@@ -2899,7 +2899,6 @@ numberofedits
 numberoffiles
 numberofpages
 numberofusers
-numberofviews
 numberofwatchingusers
 numedits
 numentries
index 49e0e9d..cac33ec 100644 (file)
@@ -34,11 +34,7 @@ class InitSiteStats extends Maintenance {
        public function __construct() {
                parent::__construct();
                $this->mDescription = "Re-initialise the site statistics tables";
-               $this->addOption(
-                       'update',
-                       'Update the existing statistics (preserves the ss_total_views field)'
-               );
-               $this->addOption( 'noviews', "Don't update the page view counter" );
+               $this->addOption( 'update', 'Update the existing statistics' );
                $this->addOption( 'active', 'Also update active users count' );
                $this->addOption( 'use-master', 'Count using the master database' );
        }
@@ -63,12 +59,6 @@ class InitSiteStats extends Maintenance {
                $image = $counter->files();
                $this->output( "{$image}\n" );
 
-               if ( !$this->hasOption( 'noviews' ) ) {
-                       $this->output( "Counting total page views..." );
-                       $views = $counter->views();
-                       $this->output( "{$views}\n" );
-               }
-
                if ( $this->hasOption( 'update' ) ) {
                        $this->output( "\nUpdating site statistics..." );
                        $counter->refresh();
index 374a66e..370d14e 100644 (file)
@@ -44,7 +44,6 @@ class ShowSiteStats extends Maintenance {
 
        public function execute() {
                $fields = array(
-                       'ss_total_views' => 'Total views',
                        'ss_total_edits' => 'Total edits',
                        'ss_good_articles' => 'Number of articles',
                        'ss_total_pages' => 'Total pages',
index 830b02f..a85f894 100644 (file)
@@ -23,7 +23,6 @@ div#column-one,
 #toc.tochidden,
 div#f-poweredbyico,
 div#f-copyrightico,
-li#viewcount,
 li#about,
 li#disclaimer,
 li#mobileview,
index a9df683..529ab82 100644 (file)
@@ -941,7 +941,7 @@ class ParserTest {
                $tables = array( 'user', 'user_properties', 'user_former_groups', 'page', 'page_restrictions',
                        'protected_titles', 'revision', 'text', 'pagelinks', 'imagelinks',
                        'categorylinks', 'templatelinks', 'externallinks', 'langlinks', 'iwlinks',
-                       'site_stats', 'hitcounter', 'ipblocks', 'image', 'oldimage',
+                       'site_stats', 'ipblocks', 'image', 'oldimage',
                        'recentchanges', 'watchlist', 'interwiki', 'logging',
                        'querycache', 'objectcache', 'job', 'l10n_cache', 'redirect', 'querycachetwo',
                        'archive', 'user_groups', 'page_props', 'category', 'msg_resource', 'msg_resource_links'
index 4abb4e5..664f274 100644 (file)
@@ -481,7 +481,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                                'page_namespace' => 0,
                                'page_title' => ' ',
                                'page_restrictions' => null,
-                               'page_counter' => 0,
                                'page_is_redirect' => 0,
                                'page_is_new' => 0,
                                'page_random' => 0,