Extension talk:HitCounters

Jump to navigation Jump to search

About this board

Please create Phabricator tasks if you run into bugs
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:03, 30 July 2016 (UTC)

--> Archived talk

Main_Page Error: Call to undefined function HitCounters\wfMemcKey()

1
Noloader (talkcontribs)

Hi Everyone,

We run Mediawiki on a Ubuntu 20.04 server. We just upgraded from Mediawiki 1.36 to 1.36.1. Composer updated vendor stuff, and maintenance/update.php completed successfully. HitCounters is using the REL1_36 branch and up to date.

After restarting the Apache webserver we are seeing the following.

Internal error

[YNS8Yk0uwEj5gvQDE6jINAAAABk] /wiki/Main_Page Error: Call to undefined function HitCounters\wfMemcKey()

Backtrace:

from /var/www/html/w/extensions/HitCounters/includes/HitCounters.body.php(37)
#0 /var/www/html/w/extensions/HitCounters/includes/HitCounters.hooks.php(153): HitCounters\HitCounters::getCount()
#1 /var/www/html/w/includes/HookContainer/HookContainer.php(338): HitCounters\Hooks::onSkinTemplateOutputPageBeforeExec()
#2 /var/www/html/w/includes/HookContainer/HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook()
#3 /var/www/html/w/includes/HookContainer/HookRunner.php(3612): MediaWiki\HookContainer\HookContainer->run()
#4 /var/www/html/w/includes/skins/SkinTemplate.php(403): MediaWiki\HookContainer\HookRunner->onSkinTemplateOutputPageBeforeExec()
#5 /var/www/html/w/includes/skins/SkinTemplate.php(129): SkinTemplate->prepareQuickTemplate()
#6 /var/www/html/w/includes/skins/SkinTemplate.php(146): SkinTemplate->generateHTML()
#7 /var/www/html/w/includes/OutputPage.php(2634): SkinTemplate->outputPage()
#8 /var/www/html/w/includes/MediaWiki.php(927): OutputPage->output()
#9 /var/www/html/w/includes/MediaWiki.php(940): MediaWiki::{closure}()
#10 /var/www/html/w/includes/MediaWiki.php(546): MediaWiki->main()
#11 /var/www/html/w/index.php(53): MediaWiki->run()
#12 /var/www/html/w/index.php(46): wfIndexMain()
#13 {main}


Noloader (talk) 17:17, 24 June 2021 (UTC)

Reply to "Main_Page Error: Call to undefined function HitCounters\wfMemcKey()"

Deprecated: Use of SkinTemplateOutputPageBeforeExec hook ... was deprecated in MediaWiki 1.35

6
Noloader (talkcontribs)

Hi Everyone,

We recently updated to Mediawiki 1.36. I'm testing some of our installed skins under it.

Most skins are causing this warning to be printed on the top of each page. But it looks like this may be a HitCounter issue:

Deprecated: Use of SkinTemplateOutputPageBeforeExec hook (used in HitCounters\Hooks::onSkinTemplateOutputPageBeforeExec) was deprecated in MediaWiki 1.35. [Called from MediaWiki\HookContainer\HookContainer::run in /var/www/html/w/includes/HookContainer/HookContainer.php at line 137] in /var/www/html/w/includes/debug/MWDebug.php on line 376

I have no idea why we are running debug code on a production server. I guess that's a separate issue for the Mediawiki folks.

My apologies if this is not a HitCounter issue.

Our mediawiki information can be found here.

WikiForMen (talkcontribs)
Noloader (talkcontribs)

WikiForMen,

I'm still not seeing the changes on the GitHub mirror. da6e220 is an older commit:

Updating extension HitCounters
Entering /var/www/html/w/extensions/HitCounters
REL1_36 branch found
HEAD is now at da6e220 build: Updating browserslist to 4.16.6

Would you happen to know when your changes are going to land in the GitHub mirror?

Thanks again.

Noloader (talkcontribs)

Thanks WikiForMen.

We use the REL1_36 branch from the HitCounter GitHub. Is the change available in REL1_36?

Thanks in advance.

WikiForMen (talkcontribs)
Noloader (talkcontribs)
Reply to "Deprecated: Use of SkinTemplateOutputPageBeforeExec hook ... was deprecated in MediaWiki 1.35"
Lamjon (talkcontribs)

After installed HitCounters, & run php update.php,

2 tables hit_counter & hit_counter_extension added to db,

but hit_counter does not update, it was empty for half days,


& SpecialPage:popularpages is empty. Any ideas?

WikiForMen (talkcontribs)
  1. May be the counting table is not updated because some kind of page cache is engaged. Please ask your webmaster.
  2. May be, you are runnig an older mediawiki version? The actual and offical HitCounters extension has no backward compatibility. In that case look on this fork.
Reply to "hit_counter not update"

Digital format for Views per edit in View statistics not displayed correctly for non-English languages

1
Summary by Kghbln

Tracked with task T280906

Kghbln (talkcontribs)

The digital format for "Views per edit" in "View statistics" not displayed correctly for non-English languages, e.g. in German "Aufrufe pro Bearbeitung" shows "21.28", should be "21,28".

Reply to "Digital format for Views per edit in View statistics not displayed correctly for non-English languages"
Lamjon (talkcontribs)

This might be a bit off the topics, we'd like to add a page/block on the home page showing all hit counters in the mediawiki, ideal format like this:

pages | hit counts (descending)

xxxx | 999

yyyy | 777

...

..


does this extensions work this way or other ext available in the market. thanks .


media wiki version 1.34.2

php: 7.x

WikiForMen (talkcontribs)

This is part of the extension:

"HitCounters displays … the most viewed pages on a special page called Special:PopularPages." - See description!

For an example see here.--WikiForMen (talk) 09:47, 9 April 2021 (UTC)

Lamjon (talkcontribs)

thanks

195.141.167.186 (talkcontribs)

Is it possible to read the total hits from the database by using the API-interface?


Kind regards from Basel, Switzerland

Thomas


MarkAHershberger (talkcontribs)
195.141.167.186 (talkcontribs)

Would be nice.

TespSam (talkcontribs)

Can I vote this up? The format of the data is difficult for my customers to import into excel.

Reply to "API and HitCounter"

"View statistics" in SpecialPages:Statistics

6
Ulf Dunkel (talkcontribs)

Is it true that the "View statistics" are being generated by the HitCounters extension?

If you e.g. watch https://en.intactiwiki.org/wiki/Special:Statistics you see this section prior to the "Most viewed pages" section which indeed reflects the hits counted by HitCounters since 2021-03-22. If so, then no other global hits counter tool might be necessary to track the total hits of a mediawiki installation, right?

I just ask this because I didn't find any information about the side-effects of HitCounters to the SpecialPages:Statistics.

WikiForMen (talkcontribs)
Ulf Dunkel (talkcontribs)

I have installed the RefreshSiteStatsTable extension now and ran it. But it makes me wonder that before I ran it, e.g. my French wiki had 8 articles, and afterwards it only counts 7. Does your script exclude the Main page? See <https://fr.intactiwiki.org/index.php/Accueil> as an example.

WikiForMen (talkcontribs)

Please take a look at the code, which is very simple:

$anzahl_counted_good = (int)$this->mDBr->selectField( 'page', 'COUNT(*)', [ 'page_namespace' => NS_MAIN, 'page_is_redirect' => 0 ], __METHOD__ );

It is a simple DB query how many entries are in the table page that have the namespace NS_MAIN and are NOT a redirect. And then updates the field ss_good_articles in the table site_stats is updated. The main page is treated like all the others. In my wiki for example the main page is not counted, because there the main page is not in the namespace NS_MAIN, but in the namespace project. The extension does in the browser what the maintenance script

php maintenance/initSiteStats.php --update

does on the command line of the server.

The result should be the same according to Adam Riese. ;-) --WikiForMen (talk) 11:16, 8 April 2021 (UTC)

WikiForMen (talkcontribs)
WikiForMen (talkcontribs)

The HitCounters extension is, of course, quite primitive tool. It does not distinguish visits from reds and other. Therefore, other tools can provide finer and completely different results. Nevertheless, I appreciate HitCounters, because I have all visits since the beginning of counting for all articles and so I can recognize by relative changes/shifts, which articles currently experience special interest.--WikiForMen (talk) 12:28, 6 April 2021 (UTC)

Reply to ""View statistics" in SpecialPages:Statistics"

Noisy during mysqlcheck --auto-repair

1
Noloader (talkcontribs)

We run mysqlcheck --auto-repair before backing up our wiki database. The hit counter is kind of noisy:

[236338]: my_wiki.wikilounge_hitcounter                      To be repaired, cause follows:
[236338]: Server issued note     : The storage engine for the table doesn't table doesn't support check

Its no big deal the hit counter storage does not support report. There's nothing to report in this instance.

Dark and silent cockpits are a good thing. Its from aviation, where pilots want lights off and no buzzers. Lights on and noises means something is going wrong and needs attention.

Perhaps it would be better to stay silent rather than raising an alarm.

Noloader (talk) 01:15, 2 April 2021 (UTC)

Reply to "Noisy during mysqlcheck --auto-repair"
Emikulic (talkcontribs)

Installing into 1.35.0 did not update the database. php update.php did nothing and I get errors on our wiki saying the table cannot be found.

[X9rTt6Dou00@cr2kmZ5c4AAAAMA] /index.php?title=Main_Page Wikimedia\Rdbms\DBQueryError from line 1699 of /var/www/mediawikis/wiki-1.35.0/includes/libs/rdbms/database/Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading?

Ulf Dunkel (talkcontribs)

Did you run /maintenance/update.php or /extensions/HitCounters/update.php? You'd run the first one.

WikiForMen (talkcontribs)

I guess, what /maintenance/update.php will run /extensions/HitCounters/update.php of all extensions.--WikiForMen (talk) 17:50, 24 March 2021 (UTC)

WikiForMen (talkcontribs)

I have just done a new installation. If the checkbox "HitCounters" is ticked during the first installation, the DB table "hit_counter" is created immediately during the first installation. If the extension HitCounters is added after the initial installation, php update.php must be called up again on the command line and the DB table "hit_counter" is created subsequently. Both variants work.

Ulf Dunkel (talkcontribs)

I see two tables: hit_counter and hit_counter_extension, the latter being empty.

Emikulic (talkcontribs)

I will have to try again. Will let you all know how it goes.

Can I edit the output string to assign a start date?

16
Ulf Dunkel (talkcontribs)

I run a wiki for several years now and have installed HitCounters as of today. Now my MainPage shows the line

"This page has been accessed 8 times."

How can I adjust these strings and add a date, like e.g.

"This page has been accessed 8 times since 2021-03-22."

I didn't find any such string in /extensions/HitCounters/i18n/ or elsewhere in its extension folder.

WikiForMen (talkcontribs)

You can edit in HitCounters/i18n/en.json

"hitcounters-viewcount": "This page has been accessed $1 times.",

and change it into

   "hitcounters-viewcount": "This page has been accessed $1 times since 2021-03-22.",

--WikiForMen (talk) 20:10, 22 March 2021 (UTC)

Kghbln (talkcontribs)

I agree it should be "hitcounters-viewcount" rather than "viewcount" starting from MW 1.36+. I tried to create a patch.

WikiForMen (talkcontribs)

He is using MW 1.32.2. The key "hitcounters-viewcount" is missing in all i18n files of the HitCounters extension. --WikiForMen (talk) 00:57, 26 March 2021 (UTC)

Kghbln (talkcontribs)

The version of HitCounters is calling the "hitcounters-viewcount" key instead of "viewcount"?

WikiForMen (talkcontribs)

As a developer I use since years my own version of extension HitCounters, compatible with 1.25+ until 1.35+, there I passed "viewcount" from /languages/i18n/en.json into "hitcounters-viewcount" in /extensions/HitCounters/i18n/en.json as all HitCounters messages have the "hitcounters-keyname" structure. See here. I have no idea, why "viewcount" was left behind in the core.--WikiForMen (talk) 14:26, 26 March 2021 (UTC)

Ulf Dunkel (talkcontribs)

Thank you for this hint, but the mentioned string is not in my en.json file which I also re-checked from the current master. Mine reads as follows:

{
"@metadata": {
"authors": [
"Mark A. Hershberger"
]
},
"hitcounters-extensionname": "Hit Counters",
"hitcounters-desc": "Provides per page view statistics",
"hitcounters-page-label": "$1",
"hitcounters-nviews": "$1 views",
"popularpages": "Popular pages",
"popularpages-summary": "",
"hitcounters-pageinfo-views": "Number of views",
"hitcounters-statistics-header-views": "View statistics",
"hitcounters-statistics-views-total": "Views total",
"hitcounters-statistics-views-total-desc": "Views to non-existing pages and special pages are not included",
"hitcounters-statistics-views-peredit": "Views per edit",
"hitcounters-statistics-mostpopular": "Most viewed pages",
"abusefilter-edit-builder-vars-page-views": "Page views",
"abusefilter-edit-builder-vars-movedfrom-views": "Source page views",
"abusefilter-edit-builder-vars-movedto-views": "Target page views"
}

So I guess the string is stored somewhere else. Any further hints?

WikiForMen (talkcontribs)

If the mentioned string is not in the en.json file, so: insert it! ;-)

It is called in the file includesHitCounters.hooks.php on line 157

$skin->msg( 'viewcount' )

Note that the HitCounters extension was outsourced from the MediaWiki's core code and that you still have the string in question in the MediaWiki's file en.json. --WikiForMen (talk) 12:57, 23 March 2021 (UTC)

Ulf Dunkel (talkcontribs)

What I found now was this:

root@ubuntu:/var/www/vhosts/intactiwiki.org/w/pool# grep -r "has been accessed" *
languages/i18n/en-gb.json:      "viewcount": "This page has been accessed $1 times.",
languages/i18n/en.json: "viewcount": "This page has been accessed $1 times.",
languages/i18n/mni.json:        "viewcount": "This page has been accessed $1 times?",
tests/parser/preprocess/All_system_messages.expected:This page has been accessed $1 times.
tests/parser/preprocess/All_system_messages.txt:This page has been accessed $1 times.

No change in any of these files shows any effect on the actual page output.

WikiForMen (talkcontribs)

As I suspected, this string is still in those files, which are from an installation prior to REL 1.25. The creators of the extension apparently forgot to transfer these entries into the extension. You can transfer them and alter them at your choice. But use "hitcounters-viewcount" instead of "viewcount" as key.--WikiForMen (talk) 13:00, 23 March 2021 (UTC)

Ulf Dunkel (talkcontribs)

I now have added two lines to my /extensions/HitCounters/i18n/en.json file:

"hitcounters-viewcount": "This page has been accessed $1 times since 2021-03-22.",
"viewcount": "This page has been accessed $1 times since 2021-03-22."

No change in my Wiki page footers afterwards. In fact, this file is being read, because when I had a typo in it, my Wiki reported a large amount of error lines until I fixed it. But neither "hitcounters-viewcount" nor "viewcount" seem to be used from this file.

WikiForMen (talkcontribs)

A. I changed it on my website and it works. See the footer here!

B. Consider caching issues!

  1. Empty the table "l10n_cache" table in your data base.
  2. Run the "runJobs.php" maintenance script.

C. You say, you have added two lines to my /extensions/HitCounters/i18n/en.json file! "en"!!! But in your wikis is $wgLanguageCode = "de"! Also in the english speaking one!

You should one line to your /extensions/HitCounters/i18n/de.json file:

"hitcounters-viewcount": "Diese Seite wurde bisher {{PLURAL:$1|einmal|$1 mal}} abgerufen seit 22. März 2021.",

--WikiForMen (talk) 17:36, 24 March 2021 (UTC)

Ulf Dunkel (talkcontribs)

Thank you for your patience with me. Where can you see how the $wgLanguageCode for my wikis is set up? I run various language instances which share a CommonSettings.php file but have their own LocalSettings.php files. A grep search for $wgLanguageCode showed only $wgLanguageCode = "en" for my English wiki. Where do I have to check this?

I tried to empty the table "l10n_cache" for my English wiki but got an empty result in phpmyadmin. What am I doing wrong?

I also added the suggested German string to /extensions/HitCounters/i18n/de.json without any change.

Even after I copied the table structure into a new table i10n_cache_backup, deleted i10n_cache, renamed (the empty) i10n_cache_backup to i10n_cache and ran php runJobs.php, there's no change in my footer output. Weird.

Any help is really appreciated.

WikiForMen (talkcontribs)

Strange! I found also in mediawiki-1.35.1/languages/i18n/de.json this:

"viewcount": "Diese Seite wurde bisher {{PLURAL:$1|einmal|$1 mal}} abgerufen.",

I was sure, that this was removed from the core.

Normally you may set $wgLanguageCode = "de"; for subdomain de.intactiwiki.org and $wgLanguageCode = "es"; for subdomain es.intactiwiki.org, respectively in the corresponding localsettings.php file.

I see on your site in de.intactiwiki.org, en.intactiwiki.org, and es.intactiwiki.org the sidebar, the tabs, and the footer in German language. So I guess that in all your localsettings.php files the variable $wgLanguageCode is set to "de". OK, I see you are using Extension:UniversalLanguageSelector.

I have no glue, what you are doing wrong. :-( You are sure to have upload de.json and en.json into the right folder?

I changed /extensions/HitCounters/i18n/en.json to this:

"hitcounters-viewcount": "This page has been accessed {{PLURAL:$1|once|$1 times}} since 2021-01-01.",

upload it with FTP, and it worked immediately (and without emptying the table "l10n_cache") on "en.wikimannia.org" as you can see yourself. --WikiForMen (talk) 00:39, 26 March 2021 (UTC)

Ulf Dunkel (talkcontribs)

I finally figured out what was going on:

  • I run MediaWiki 1.32.2 and the relevant HitCounters extension 0.3 (7638419).
  • HitCounters 0.3 uses the global "viewcount" key which should be available from /wiki/languages/i18n/'<language>.json.
  • Adding the "viewcount" key or "hitcounters-viewcount" to /extensions/HitCounters/i18n/<language>.json didn't have any effect in Hitcounters 0.3.
  • Because I run multiple language instances of a wiki which share most files from a shared pool, I tried and edited the relevant strings in /wiki/languages/i18n/<language>.json. BUT - I had overseen that all localized wiki instances still had their own /languages/ folders.
  • So I removed them and added symbolic links to /wiki/pool/languages/ in order to have all wiki instances use one shared folder.


Now everything works fine for me. I guess I have to adjust things once more when I update MediaWiki to 1.35 or higher. I stored the enhanced files for me like this:

da.json: "viewcount": "Siden er vist $1 gange siden 22. marts 2021.",

de:json: "viewcount": "Diese Seite wurde seit dem 22.03.2021 bisher $1 mal abgerufen.",

en.json: "viewcount": "This page has been accessed $1 times since 22 March 2021.",

es.json: "viewcount": "Esta página ha recibido $1 visitas desde el 22 de marzo de 2021.",

fi.json: "viewcount": "Tämä sivu on näytetty $1 kertaa 22. maaliskuuta 2021 lähtien.",

fr.json: "viewcount": "Cette page n’a jamais été consultée depuis le 22 mars 2021.",

is.json: "viewcount": "Þessi síða hefur verið skoðuð $1 sinnum síðan 22. mars 2021.",

nl.json: "viewcount": "Deze pagina is $1 keer bekeken sinds 22 maart 2021.",

sv:json: "viewcount": "Den här sidan har visats $1 gånger sedan 22 mars 2021.",

sw.json: "viewcount": "Ukurasa huu umetembelewa mara $1 tangu Machi 22, 2021.",

tr.json: "viewcount": "Bu sayfaya 22 Mart 2021 tarihinden $1 defa erişilmiş.",


As I am not familiar with Arabic, Farsi, Hebrew and find editing rtl texts in Ubuntu's nano editor rather difficult, I left those three languages for my wiki instances untouched so far.

WikiForMen (talkcontribs)
"BUT - I had overseen that all localized wiki instances still had their own /languages/ folders."

I was afraid about something like this! ;-) --WikiForMen (talk) 13:42, 26 March 2021 (UTC)