wfSeedRandom();
if ( 0 == mt_rand( 0, 999 ) ) {
+ # Periodically flush old entries from the recentchanges table.
+ global $wgRCMaxAge;
$dbw =& wfGetDB( DB_MASTER );
- $cutoff = $dbw->timestamp( time() - ( 7 * 86400 ) );
+ $cutoff = $dbw->timestamp( time() - $wgRCMaxAge );
$sql = "DELETE FROM recentchanges WHERE rc_timestamp < '{$cutoff}'";
$dbw->query( $sql );
}
# Log IP addresses in the recentchanges table
$wgPutIPinRC = false;
+# Recentchanges items are periodically purged;
+# entries older than this many seconds will go.
+$wgRCMaxAge = 7 * 24 * 3600; # our one week cutoff
+
# RDF metadata toggles
$wgEnableDublinCoreRdf = false;
$wgEnableCreativeCommonsRdf = false;
$now = $this->mAttribs['rc_timestamp'];
$curId = $this->mAttribs['rc_cur_id'];
- # Update rc_this_oldid for the entries which were current
- $dbw->update( 'recentchanges',
- array( /* SET */
- 'rc_this_oldid' => $oldid
- ), array( /* WHERE */
- 'rc_namespace' => $ns,
- 'rc_title' => $title,
- 'rc_timestamp' => $dbw->timestamp($lastTime)
- ), $fname
- );
+ # Don't bother looking for entries that have probably
+ # been purged, it just locks up the indexes needlessly.
+ global $wgRCMaxAge;
+ $age = time() - wfTimestamp( TS_UNIX, $lastTime );
+ if( $age < $wgRCMaxAge ) {
+ # Update rc_this_oldid for the entries which were current
+ $dbw->update( 'recentchanges',
+ array( /* SET */
+ 'rc_this_oldid' => $oldid
+ ), array( /* WHERE */
+ 'rc_namespace' => $ns,
+ 'rc_title' => $title,
+ 'rc_timestamp' => $dbw->timestamp( $lastTime )
+ ), $fname
+ );
+ }
# Update rc_cur_time
$dbw->update( 'recentchanges', array( 'rc_cur_time' => $now ),