Last modified: 2012-01-26 22:09:13 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T35911, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 33911 - Unused ss_admins value may fail SiteStats sanity check
Unused ss_admins value may fail SiteStats sanity check
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Database (Other open bugs)
1.20.x
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-01-23 21:36 UTC by Freek Dijkstra
Modified: 2012-01-26 22:09 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
fix for the described bug. Ignore the unused ss_admins field in the sanity check. (452 bytes, patch)
2012-01-23 21:36 UTC, Freek Dijkstra
Details

Description Freek Dijkstra 2012-01-23 21:36:24 UTC
Created attachment 9898 [details]
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"
4. 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.

2. 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".

3. 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.
Comment 1 Freek Dijkstra 2012-01-23 21:39:48 UTC
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.)
Comment 2 Chad H. 2012-01-26 22:09:13 UTC
Fixed in r110088/r110090 and the only extension in r110089.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links