Page MenuHomePhabricator

Division by zero in SpecialStatistics.php
Closed, ResolvedPublic

Description

$ w3m -dump \
http://radioscanningtw.jidanni.org/index.php?title=Special:Statistics |
head -3

Warning: Division by zero in ...SpecialStatistics.php on line 53


Version: 1.9.x
Severity: minor
OS: Linux
Platform: PC

Details

Reference
bz9421

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:40 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz9421.
bzimport added a subscriber: Unknown Object (MLST).

robchur wrote:

Please state the value of site_stats.ss_users; I'm guessing it will be zero.
This sounds like another "messed up statistics table" bug.

Must be 0 I suppose too. Maybe I will check it when I supposedly get ADSL.

Moral of story: always check for 0 before dividing external items anyway!

Well, it turns out there is nothing there:

  • Dumping data for table wiki_site_stats

/*!40000 ALTER TABLE wiki_site_stats DISABLE KEYS */;
LOCK TABLES wiki_site_stats WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE wiki_site_stats ENABLE KEYS */;

So at least be prepared for that possibility when writing the code.
Hmmm, how shall I medicate that condition best?

By the way, here are some other wiki observations that I hope your
code is prepared for: ss_admins: -1 ss_images: 0 ss_good_articles:
18446744073709551615

robchur wrote:

You can run maintenance/initStats.php to initialise the site_stats table, or
indeed, reset the whole thing if it turns bad.

Checking for a missing or invalid site_stats row appears to have been added in
trunk...