jenkins-bot has submitted this change and it was merged. Change subject: Remove hitcounters and associated code ......................................................................
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 --- M RELEASE-NOTES-1.25 M includes/AutoLoader.php M includes/DefaultSettings.php M includes/MagicWord.php M includes/Setup.php M includes/SiteStats.php M includes/actions/InfoAction.php M includes/api/ApiQueryInfo.php M includes/api/ApiQuerySiteinfo.php M includes/deferred/SiteStatsUpdate.php D includes/deferred/ViewCountUpdate.php M includes/page/WikiPage.php M includes/parser/CoreParserFunctions.php M includes/parser/Parser.php M includes/skins/SkinTemplate.php M includes/specialpage/QueryPage.php M includes/specialpage/SpecialPageFactory.php D includes/specials/SpecialPopularpages.php M includes/specials/SpecialStatistics.php M languages/i18n/en.json M languages/i18n/qqq.json M languages/messages/MessagesEn.php M maintenance/dictionary/mediawiki.dic M maintenance/initSiteStats.php M maintenance/showSiteStats.php M resources/src/mediawiki.legacy/commonPrint.css M tests/parser/parserTest.inc M tests/phpunit/MediaWikiTestCase.php 28 files changed, 23 insertions(+), 449 deletions(-) Approvals: Aaron Schulz: Looks good to me, approved jenkins-bot: Verified diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25 index 862b132..ee3db43 100644 --- a/RELEASE-NOTES-1.25 +++ b/RELEASE-NOTES-1.25 @@ -61,6 +61,7 @@ * 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 2a45fc3..ab533d2 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -474,7 +474,6 @@ '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 @@ '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 f2453e8..d89be1d 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4116,15 +4116,6 @@ $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 * {{NUMBEROFACTIVEUSERS}} magic word in wikitext. @@ -5383,12 +5374,6 @@ * @since 1.22 */ $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). diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 4d17298..d281555 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -172,7 +172,6 @@ 'directionmark', 'contentlanguage', 'numberofadmins', - 'numberofviews', 'cascadingsources', ); @@ -215,7 +214,6 @@ 'localtimestamp' => 3600, 'pagesinnamespace' => 3600, 'numberofadmins' => 3600, - 'numberofviews' => 3600, 'numberingroup' => 3600, ); diff --git a/includes/Setup.php b/includes/Setup.php index 743936e..2faf196 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -517,6 +517,10 @@ 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 3dc1793..32c6761 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -102,7 +102,6 @@ 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 @@ } /** + * 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 @@ } // Now check for underflow/overflow foreach ( array( - 'ss_total_views', 'ss_total_edits', 'ss_good_articles', 'ss_total_pages', @@ -274,7 +277,7 @@ // Various stats private $mEdits = null, $mArticles = null, $mPages = null; - private $mUsers = null, $mViews = null, $mFiles = null; + private $mUsers = null, $mFiles = null; /** * Constructor @@ -349,15 +352,6 @@ } /** - * 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 @@ * - 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 @@ $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 @@ } /** - * 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 @@ '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 f932a405..12e845b 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -314,13 +314,6 @@ $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' ) || @@ -643,17 +636,6 @@ $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( diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index d7037e3..0c93507 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -64,9 +64,6 @@ } $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 @@ : 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 @@ 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 311438f..feb869e 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -481,9 +481,6 @@ $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 7bfafee..97a17c3 100644 --- a/includes/deferred/SiteStatsUpdate.php +++ b/includes/deferred/SiteStatsUpdate.php @@ -23,9 +23,6 @@ */ class SiteStatsUpdate implements DeferrableUpdate { /** @var int */ - protected $views = 0; - - /** @var int */ protected $edits = 0; /** @var int */ @@ -42,7 +39,6 @@ // @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 @@ } $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 @@ // 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 @@ } 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 @@ 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 8282295..0000000 --- a/includes/deferred/ViewCountUpdate.php +++ /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' ); - } -} diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 9ade16e..81c93a1 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -89,11 +89,6 @@ 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 @@ */ 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 @@ $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 ); @@ -474,17 +467,6 @@ */ public function hasViewableContent() { 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; } /** @@ -1183,15 +1165,8 @@ * @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 @@ -1262,7 +1237,6 @@ '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 355a3c1..8828826 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -44,7 +44,7 @@ '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', @@ -488,10 +488,6 @@ } 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 ddd1f9a..e6478a4 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3155,10 +3155,6 @@ 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 c1db302..7ef3a8f 100644 --- a/includes/skins/SkinTemplate.php +++ b/includes/skins/SkinTemplate.php @@ -260,7 +260,7 @@ */ protected function prepareQuickTemplate() { global $wgContLang, $wgScript, $wgStylePath, $wgMimeType, $wgJsMimeType, - $wgDisableCounters, $wgSitename, $wgLogo, $wgMaxCredits, + $wgSitename, $wgLogo, $wgMaxCredits, $wgShowCreditsIfMax, $wgArticlePath, $wgScriptPath, $wgServer; @@ -373,19 +373,13 @@ $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 @@ $tpl->set( 'footerlinks', array( 'info' => array( 'lastmod', - 'viewcount', 'numberofwatchingusers', 'credits', 'copyright', diff --git a/includes/specialpage/QueryPage.php b/includes/specialpage/QueryPage.php index b229e06..167135b 100644 --- a/includes/specialpage/QueryPage.php +++ b/includes/specialpage/QueryPage.php @@ -60,7 +60,6 @@ * @return array */ public static function getPages() { - global $wgDisableCounters; static $qp = null; if ( $qp === null ) { @@ -102,10 +101,6 @@ 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 9a6b787..cba4d13 100644 --- a/includes/specialpage/SpecialPageFactory.php +++ b/includes/specialpage/SpecialPageFactory.php @@ -214,7 +214,7 @@ */ private static function getPageList() { global $wgSpecialPages; - global $wgDisableCounters, $wgDisableInternalSearch, $wgEmailAuthentication; + global $wgDisableInternalSearch, $wgEmailAuthentication; global $wgEnableEmail, $wgEnableJavaScriptTest; global $wgPageLanguageUseDB; @@ -222,10 +222,6 @@ wfProfileIn( __METHOD__ ); 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 2a80f65..0000000 --- a/includes/specials/SpecialPopularpages.php +++ /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'; - } -} diff --git a/includes/specials/SpecialStatistics.php b/includes/specials/SpecialStatistics.php index f0e360e..1bbc2f3 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 @@ 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(); @@ -52,12 +50,6 @@ $this->users = SiteStats::users(); $this->activeUsers = SiteStats::activeUsers(); $this->hook = ''; - - # Staticic - views - $viewsStats = ''; - if ( !$disableCounters ) { - $viewsStats = $this->getViewsStats(); - } # Set active user count if ( !$miserMode ) { @@ -83,12 +75,6 @@ # Statistic - usergroups $text .= $this->getGroupStats(); - $text .= $viewsStats; - - # Statistic - popular pages - if ( !$disableCounters && !$miserMode ) { - $text .= $this->getMostViewedPages(); - } # Statistic - other $extraStats = array(); @@ -232,63 +218,6 @@ $text .= $this->formatRow( $grouppage . ' ' . $grouplink, $this->getLanguage()->formatNum( $countUsers ), array( 'class' => 'statistics-group-' . Sanitizer::escapeClass( $group ) . $classZero ) ); - } - - 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; diff --git a/languages/i18n/en.json b/languages/i18n/en.json index fc47178..ab44ca2 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 20d0618..a6f0fa6 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 <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}}", @@ -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 0a10279..f1238b6 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -240,7 +240,6 @@ '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 99f43ff..ad8b004 100644 --- a/maintenance/dictionary/mediawiki.dic +++ b/maintenance/dictionary/mediawiki.dic @@ -2899,7 +2899,6 @@ numberoffiles numberofpages numberofusers -numberofviews numberofwatchingusers numedits numentries diff --git a/maintenance/initSiteStats.php b/maintenance/initSiteStats.php index 49e0e9d..cac33ec 100644 --- a/maintenance/initSiteStats.php +++ b/maintenance/initSiteStats.php @@ -34,11 +34,7 @@ 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' ); } @@ -62,12 +58,6 @@ $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..." ); diff --git a/maintenance/showSiteStats.php b/maintenance/showSiteStats.php index 374a66e..370d14e 100644 --- a/maintenance/showSiteStats.php +++ b/maintenance/showSiteStats.php @@ -44,7 +44,6 @@ 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 830b02f..a85f894 100644 --- a/resources/src/mediawiki.legacy/commonPrint.css +++ b/resources/src/mediawiki.legacy/commonPrint.css @@ -23,7 +23,6 @@ #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 a9df683..529ab82 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -941,7 +941,7 @@ $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 4abb4e5..664f274 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -481,7 +481,6 @@ 'page_namespace' => 0, 'page_title' => ' ', 'page_restrictions' => null, - 'page_counter' => 0, 'page_is_redirect' => 0, 'page_is_new' => 0, 'page_random' => 0, -- To view, visit https://gerrit.wikimedia.org/r/150699 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0e5006a7e8a09c800f8fa4effa9399e8afdd7a57 Gerrit-PatchSet: 21 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Chad <ch...@wikimedia.org> Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Anomie <bjor...@wikimedia.org> Gerrit-Reviewer: Chad <ch...@wikimedia.org> Gerrit-Reviewer: Cscott <canan...@wikimedia.org> Gerrit-Reviewer: Daniel Friesen <dan...@nadir-seen-fire.com> Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net> Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: MZMcBride <w...@mzmcbride.com> Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com> Gerrit-Reviewer: PleaseStand <pleasest...@live.com> Gerrit-Reviewer: Springle <sprin...@wikimedia.org> Gerrit-Reviewer: Umherirrender <umherirrender_de...@web.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits