From 90d90dad6e4d463b3db425d78f7ed1e084ca0816 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 30 Jul 2014 13:56:20 -0700 Subject: [PATCH] Remove hitcounters and associated code 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 --- RELEASE-NOTES-1.25 | 1 + includes/AutoLoader.php | 2 - includes/DefaultSettings.php | 15 --- includes/MagicWord.php | 2 - includes/Setup.php | 4 + includes/SiteStats.php | 35 ++---- includes/actions/InfoAction.php | 18 --- includes/api/ApiQueryInfo.php | 9 -- includes/api/ApiQuerySiteinfo.php | 3 - includes/deferred/SiteStatsUpdate.php | 9 +- includes/deferred/ViewCountUpdate.php | 119 ------------------ includes/page/WikiPage.php | 26 ---- includes/parser/CoreParserFunctions.php | 6 +- includes/parser/Parser.php | 4 - includes/skins/SkinTemplate.php | 11 +- includes/specialpage/QueryPage.php | 5 - includes/specialpage/SpecialPageFactory.php | 6 +- includes/specials/SpecialPopularpages.php | 89 ------------- includes/specials/SpecialStatistics.php | 73 +---------- languages/i18n/en.json | 8 -- languages/i18n/qqq.json | 8 -- languages/messages/MessagesEn.php | 1 - maintenance/dictionary/mediawiki.dic | 1 - maintenance/initSiteStats.php | 12 +- maintenance/showSiteStats.php | 1 - .../src/mediawiki.legacy/commonPrint.css | 1 - tests/parser/parserTest.inc | 2 +- tests/phpunit/MediaWikiTestCase.php | 1 - 28 files changed, 23 insertions(+), 449 deletions(-) delete mode 100644 includes/deferred/ViewCountUpdate.php delete mode 100644 includes/specials/SpecialPopularpages.php diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25 index 862b132a4e..ee3db43887 100644 --- a/RELEASE-NOTES-1.25 +++ b/RELEASE-NOTES-1.25 @@ -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 == diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 2a45fc35fa..ab533d224c 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -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', diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index f2453e842a..d89be1df41 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 4d17298b23..d281555296 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -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, ); diff --git a/includes/Setup.php b/includes/Setup.php index 743936e6ad..2faf1960ea 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -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' ); diff --git a/includes/SiteStats.php b/includes/SiteStats.php index 3dc17933b0..32c6761372 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -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 ); diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index f932a40543..12e845b423 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -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', diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index d7037e3a19..0c935078f9 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -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] ) { diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 311438fd0e..feb869e8b5 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -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() ); diff --git a/includes/deferred/SiteStatsUpdate.php b/includes/deferred/SiteStatsUpdate.php index 7bfafee845..97a17c3911 100644 --- a/includes/deferred/SiteStatsUpdate.php +++ b/includes/deferred/SiteStatsUpdate.php @@ -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 index 8282295bb1..0000000000 --- a/includes/deferred/ViewCountUpdate.php +++ /dev/null @@ -1,119 +0,0 @@ -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' ); - } -} diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 9ade16e5af..81c93a1f32 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -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, diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 355a3c1216..8828826951 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -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 ); } diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index ddd1f9a3b9..e6478a4ed9 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -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; diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php index c1db302ded..7ef3a8f56e 100644 --- a/includes/skins/SkinTemplate.php +++ b/includes/skins/SkinTemplate.php @@ -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', diff --git a/includes/specialpage/QueryPage.php b/includes/specialpage/QueryPage.php index b229e06e61..167135ba34 100644 --- a/includes/specialpage/QueryPage.php +++ b/includes/specialpage/QueryPage.php @@ -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; diff --git a/includes/specialpage/SpecialPageFactory.php b/includes/specialpage/SpecialPageFactory.php index 9a6b787d2f..cba4d13763 100644 --- a/includes/specialpage/SpecialPageFactory.php +++ b/includes/specialpage/SpecialPageFactory.php @@ -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 index 2a80f65179..0000000000 --- a/includes/specials/SpecialPopularpages.php +++ /dev/null @@ -1,89 +0,0 @@ - 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'; - } -} diff --git a/includes/specials/SpecialStatistics.php b/includes/specials/SpecialStatistics.php index f0e360e896..1bbc2f38c2 100644 --- a/includes/specials/SpecialStatistics.php +++ b/includes/specials/SpecialStatistics.php @@ -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 ([][] = number) pattern diff --git a/languages/i18n/en.json b/languages/i18n/en.json index fc47178d4e..ab44ca2d91 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1526,7 +1526,6 @@ "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", @@ -1535,13 +1534,9 @@ "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": "", @@ -1594,8 +1589,6 @@ "unusedcategories-summary": "", "unusedimages": "Unused files", "unusedimages-summary": "", - "popularpages": "Popular pages", - "popularpages-summary": "", "wantedcategories": "Wanted categories", "wantedcategories-summary": "", "wantedpages": "Wanted pages", @@ -2519,7 +2512,6 @@ "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", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 20d0618508..a6f0fa63ea 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -1688,7 +1688,6 @@ "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}}", @@ -1697,13 +1696,9 @@ "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 $wgRCMaxAge 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}}", @@ -1756,8 +1751,6 @@ "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}}", @@ -2681,7 +2674,6 @@ "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]", diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 0a102799c7..f1238b627f 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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' ), diff --git a/maintenance/dictionary/mediawiki.dic b/maintenance/dictionary/mediawiki.dic index 99f43ff8b9..ad8b004aad 100644 --- a/maintenance/dictionary/mediawiki.dic +++ b/maintenance/dictionary/mediawiki.dic @@ -2899,7 +2899,6 @@ numberofedits numberoffiles numberofpages numberofusers -numberofviews numberofwatchingusers numedits numentries diff --git a/maintenance/initSiteStats.php b/maintenance/initSiteStats.php index 49e0e9d71e..cac33ecc49 100644 --- a/maintenance/initSiteStats.php +++ b/maintenance/initSiteStats.php @@ -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(); diff --git a/maintenance/showSiteStats.php b/maintenance/showSiteStats.php index 374a66e92d..370d14eba0 100644 --- a/maintenance/showSiteStats.php +++ b/maintenance/showSiteStats.php @@ -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', diff --git a/resources/src/mediawiki.legacy/commonPrint.css b/resources/src/mediawiki.legacy/commonPrint.css index 830b02fa67..a85f89495b 100644 --- a/resources/src/mediawiki.legacy/commonPrint.css +++ b/resources/src/mediawiki.legacy/commonPrint.css @@ -23,7 +23,6 @@ div#column-one, #toc.tochidden, div#f-poweredbyico, div#f-copyrightico, -li#viewcount, li#about, li#disclaimer, li#mobileview, diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index a9df6832eb..529ab82fc2 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -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' diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 4abb4e5cf2..664f274def 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -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, -- 2.20.1