* (bug 730) configurable $wgRCMaxAge; don't try to update purged RC entries
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 19 Jan 2005 03:54:43 +0000 (03:54 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 19 Jan 2005 03:54:43 +0000 (03:54 +0000)
includes/Article.php
includes/DefaultSettings.php
includes/RecentChange.php

index 56055cc..93a1016 100644 (file)
@@ -1815,8 +1815,10 @@ class Article {
 
                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 );
                }
index 785d562..f3b5b88 100644 (file)
@@ -721,6 +721,10 @@ $wgRCSeconds = false;
 # 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;
index 2f15679..48fd45f 100644 (file)
@@ -131,16 +131,22 @@ class RecentChange
                        $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 ),