Extension:HitCounters

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
HitCounters

Release status:Extension status experimental

ImplementationTemplate:Extension#type Database, Data extraction
DescriptionTemplate:Extension#description Provide the page views functionality
Author(s)Template:Extension#username Mark A. Hershberger (MarkAHershbergertalk)
Latest versionTemplate:Extension#version 0.3 (2015-11-24)
MediaWikiTemplate:Extension#mediawiki 1.25
PHPTemplate:Extension#php 5.3+
Database changesTemplate:Extension#needs-updatephp Yes
LicenseTemplate:Extension#license GNU General Public License 3.0 or later
Download
ParametersTemplate:Extension#parameters
Hooks usedTemplate:Extension#hook
SpecialPage_initListManual:Hooks/SpecialPage_initList
SpecialStatsAddExtraManual:Hooks/SpecialStatsAddExtra
LoadExtensionSchemaUpdatesManual:Hooks/LoadExtensionSchemaUpdates
MagicWordwgVariableIDsManual:Hooks/MagicWordwgVariableIDs
ParserGetVariableValueSwitchManual:Hooks/ParserGetVariableValueSwitch
ParserFirstCallInitManual:Hooks/ParserFirstCallInit
PageViewUpdates
SkinTemplateOutputPageBeforeExecManual:Hooks/SkinTemplateOutputPageBeforeExec

Translate the HitCounters extension if it is available at translatewiki.net

Check usage and version matrix.

IssuesPhabricator

Open tasks · Report a bug

The HitCounters extension provides the page views functionality that was removed in MediaWiki 1.25.

Installation[edit]

Currently it is only possible to migrate wikis using MW 1.25 to use this extension. A fresh install in MW 1.26 and higher is not possible! Attention: If you do not act according to the following instructions, an update to MediaWiki 1.26 or newer can permanently delete your hitcounter numbers! See task T120216.


If you want to update MediaWiki to version 1.26, currently the following steps have to be done in order to prevent loss of hitcounter numbers:

  • Use MediaWiki 1.25 and install this extension.
  • Still in MediaWiki 1.25, run update.php. This step is mandatory! This should migrate the hitcounter data to the new locations:
    • Table hit_counter should exist and should contain all the hit numbers
    • Table hit_counter_extension should exist (and possibly contain information on the few, newest hits)
    • Note that I have not tested, if this actually works! The SQL files, which are included with the HitCounters extension, demonstrate the SQL commands, which have to be run before(!) running update.php in MediaWiki 1.26, in order to preserve the existing data.


  • After the above steps, update to MediaWiki 1.26 or newer. Running update.php in that version will still remove hitcounter data from the old locations, as far as it is still present there. However, since you have done the migration, the extension should continue working!
  • Download and place the file(s) in a directory called HitCounters in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'HitCounters' );
    
  • Run the update script which will automatically create the necessary database tables that this extension needs.
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

To users running MediaWiki 1.24 or earlier:

The instructions above describe the new way of installing this extension using wfLoadExtension() If you need to install this extension on these earlier versions (MediaWiki 1.24 and earlier), instead of wfLoadExtension( 'HitCounters' );, you need to use:

require_once "$IP/extensions/HitCounters/HitCounters.php";

Differences from core MediaWiki implementation[edit]

Before MediaWiki 1.25, the page views counting functionality was in core MediaWiki. This extension is based on that same code, but was deliberately done in a more lightweight way in order to speed up processing time. Many lines of superfluous code were removed. Also, the old MediaWiki core code did numerous database queries on every page hit; these have all been removed as well. This change may possibly lead to some inaccuracies in the data.

The core differences that wiki administrators need to know are:

  • The hit counts are stored in cache.
  • The visible hit count at the bottom of each page is updated only once per day. (Pages with hit count less than 100 are updated once per minute.)
  • If you refresh your browser on a wiki page, that hit is ignored.

Incompatible extensions[edit]

I need bug reports in Phabricator so that they can be worked on. If you run into a problem with one of the following, please create a phabricator task and link to it here. -- MarkAHershberger(talk) 16:02, 30 July 2016 (UTC)

References[edit]