Author: software
Description:
fix for the described bug. Ignore the unused ss_admins field in the sanity check.
Summary:
The maintenance/initStats.php script, when called, sets the value of the ss_admin column of the site_stats table to -1. When the Special:Statistics page is loaded, this negative value is considered an error, leading to an otherwise perfectly fine database to be flagged as "unsane".
Steps to reproduce
- View the site_stats table of a MediaWiki installation. Observe that there is one row, and the ss_admins row is a positive integer, typically "0".
- Run maintenance/initStats.php --active --update
- View the site_stats table of a MediaWiki installation. Observe the ss_admins row is now negative, "-1".
- Observe that the ss_active_users fields is a positive integer, lets say "A"
- View the Special:Statistics page of the MediaWiki. View the result after "Active users (list of members)".
Expected Results:
I expected Special:Statistics to list the actual number of active users.
Actual Result:
I expected Special:Statistics lists "-1" active users.
Regression:
- The initStats.php deletes and recreates the single record in the site_stats database, without explicitly setting the ss_admins field. Since the ss_admins field has a default value of -1, this is the value that is set after initStats.php is called.
- In includes/SiteStats.php, the SiteStats::isSane function checks the value of each row in the site_stats table if the value is in the range 0...2000000000. If it is not, the site statistics are marked as "unsane".
- If the site statistics are marked as "unsane" even after a reload of the values, the SiteStats::loadAndLazyInit() function calls SiteStatsInit::doAllAndCommit() without options parameter. doAllAndCommit() without $options['activeUsers'] reset the active user count to -1, and that is the value that is incorrectly shown in the Special:Statistics page.
Recommended fix:
This problem can be fix in 4 distinct ways:
- Set the default value of sitestats:ss_admins field to 0 instead of -1.
- Let the initStats.php script set the ss_admins field to a non-negative value.
- Change the sanity check to ignore the unused ss_admins record.
- Call SiteStatsInit::doAllAndCommit() with $options['activeUsers'] from SiteStats::loadAndLazyInit()
I recommend the third fix. A patch is attached.
Version: 1.20.x
Severity: normal
Attached: