Page MenuHomePhabricator

RebuildRecentChanges logic error
Closed, ResolvedPublic

Description

Author: jpotkanski

Description:
I spent the morning with rebuildrecentchanges.inc ...

Background: I had a user who was complaining the watchlist history was too
short. Wikipedia's is 30 days, yet default Mediawiki is only 7 days. This
required changing from $wgRCMaxAge = 7 * 24 * 3600; to $wgRCMaxAge = 30 * 24 *
3600; I could have just left it and said watchlists will appear correct from
now on...but rebuilding the recentchanges table looked tempting.

Bug: After running rebuildrecentchanges.php on a heavily edited wiki, recent
changes appears "empty."

Cause: Debugging found a hard coded limit 5000 in rebuildrecentchanges.inc and
a logic error with the ORDER BY. ORDER BY defaults to an ascending sort with
timestamps. If you hit the hard coded limit, your recent changes table will
only show a few days in the deep past. Ex: If the range was April 23rd to March
23rd, the rebuild only populated the recentchanges table from March 23rd to
March 29th. Expected behavior would be that it would populate from April 23rd
back until it hit either the limit or time() - $wgRCMaxAge.

Fix:

  • Add DESC to ORDER BY: array( 'ORDER BY' => 'rev_timestamp DESC', 'LIMIT' =>

5000 )

  • Raise Limit: array( 'ORDER BY' => 'rev_timestamp DESC', 'LIMIT' => 100000 )
  • or Eliminate Limit: array( 'ORDER BY' => 'rev_timestamp DESC' )

Suggestion:

  • Default $wgRCMaxAge = 7 * 24 * 3600; is a bit low, suggest $wgRCMaxAge = 60 *

24 * 3600; which is twice the Wikipedia setting.


Version: unspecified
Severity: minor

Details

Reference
bz9669

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:37 PM
bzimport set Reference to bz9669.
bzimport added a subscriber: Unknown Object (MLST).

The order was broken during the 1.5 schema change; fixed in r21628