Page MenuHomePhabricator

Hit Count reported in Popular Pages is incorrect
Closed, ResolvedPublicBUG REPORT

Description

https://www.egtre.info/wiki/Main_Page

This MediaWiki-based wiki has been running for some years without issues. I added the HitCounters extension when that was removed from the main software install; again, no issues until recently.

A few days ago I updated the site to version 1.38.1. HitCounters extension is 0.3.4.

in Special Pages -> Popular Pages, all pages show the same (large) hit count as the site's Main Page.

The hit count at the bottom of each page is still correct, and increments when the page is refreshed.

I assume the bug was not there with the previous MediaWiki version 1.37.1, I think I would have noticed.

Event Timeline

This is caused by rEHTC6827d8cdd7420074c50d38a8724c72fac5feac32: the SQL query constructed by MediaWiki is SELECT … FROM page p,hit_counter h ORDER BY … instead of SELECT … FROM hit_counter h JOIN page p ON ((p.page_id = h.page_id)) ORDER BY … (I removed the backticks here for readability), so a cross product is computed by MySQL instead of a JOIN.

This has the consequence reported in Special:PopularPages and, for big wikis, the display of Special:Statistics (with the 10 most popular pages) make MySQL creating a very big temporary table in /tmp (dozen of GiB), which could exhaust whole disk space.

I submit the proposed patch.

Change 861427 had a related patch set uploaded (by Seb35; author: Seb35):

[mediawiki/extensions/HitCounters@master] Fix the SQL request

https://gerrit.wikimedia.org/r/861427

The code change works for me on my WIki as per the original description.

Change 861427 merged by jenkins-bot:

[mediawiki/extensions/HitCounters@master] Fix the SQL request

https://gerrit.wikimedia.org/r/861427

Change 861473 had a related patch set uploaded (by Umherirrender; author: Seb35):

[mediawiki/extensions/HitCounters@REL1_39] Fix the SQL request

https://gerrit.wikimedia.org/r/861473

Change 861474 had a related patch set uploaded (by Umherirrender; author: Seb35):

[mediawiki/extensions/HitCounters@REL1_38] Fix the SQL request

https://gerrit.wikimedia.org/r/861474

Umherirrender assigned this task to Seb35.
Umherirrender subscribed.

I have also backported the fix to the affected releases. Sorry for the issue.

Change 861473 merged by jenkins-bot:

[mediawiki/extensions/HitCounters@REL1_39] Fix the SQL request

https://gerrit.wikimedia.org/r/861473

Change 861474 merged by jenkins-bot:

[mediawiki/extensions/HitCounters@REL1_38] Fix the SQL request

https://gerrit.wikimedia.org/r/861474