Page MenuHomePhabricator

Unused ss_admins value may fail SiteStats sanity check
Closed, ResolvedPublic

Description

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

  1. 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".
  2. Run maintenance/initStats.php --active --update
  3. View the site_stats table of a MediaWiki installation. Observe the ss_admins row is now negative, "-1".
  4. Observe that the ss_active_users fields is a positive integer, lets say "A"
  5. 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:

  1. 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.
  1. 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".
  1. 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:

  1. Set the default value of sitestats:ss_admins field to 0 instead of -1.
  2. Let the initStats.php script set the ss_admins field to a non-negative value.
  3. Change the sanity check to ignore the unused ss_admins record.
  4. 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:

Details

Reference
bz33911

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 12:03 AM
bzimport set Reference to bz33911.
bzimport added a subscriber: Unknown Object (MLST).

software wrote:

Forget to put in the summary: according to maintenance/tables.sql, the ss_admins field is not used:

  • Deprecated, no longer updated as of 1.5 ss_admins int default '-1',

Hence I recommend not to check its value in SiteStats::isSane() anymore.

(PS: The "I expected " after "Actual Result:" in the bug report is spurious. Sorry about that.)

Fixed in r110088/r110090 and the only extension in r110089.