r7170 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r7169‎ | r7170 | r7171 >
Date:03:54, 19 January 2005
Author:vibber
Status:old
Tags:
Comment:
* (bug 730) configurable $wgRCMaxAge; don't try to update purged RC entries
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/RecentChange.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -1815,8 +1815,10 @@
18161816
18171817 wfSeedRandom();
18181818 if ( 0 == mt_rand( 0, 999 ) ) {
 1819+ # Periodically flush old entries from the recentchanges table.
 1820+ global $wgRCMaxAge;
18191821 $dbw =& wfGetDB( DB_MASTER );
1820 - $cutoff = $dbw->timestamp( time() - ( 7 * 86400 ) );
 1822+ $cutoff = $dbw->timestamp( time() - $wgRCMaxAge );
18211823 $sql = "DELETE FROM recentchanges WHERE rc_timestamp < '{$cutoff}'";
18221824 $dbw->query( $sql );
18231825 }
Index: trunk/phase3/includes/RecentChange.php
@@ -131,16 +131,22 @@
132132 $now = $this->mAttribs['rc_timestamp'];
133133 $curId = $this->mAttribs['rc_cur_id'];
134134
135 - # Update rc_this_oldid for the entries which were current
136 - $dbw->update( 'recentchanges',
137 - array( /* SET */
138 - 'rc_this_oldid' => $oldid
139 - ), array( /* WHERE */
140 - 'rc_namespace' => $ns,
141 - 'rc_title' => $title,
142 - 'rc_timestamp' => $dbw->timestamp($lastTime)
143 - ), $fname
144 - );
 135+ # Don't bother looking for entries that have probably
 136+ # been purged, it just locks up the indexes needlessly.
 137+ global $wgRCMaxAge;
 138+ $age = time() - wfTimestamp( TS_UNIX, $lastTime );
 139+ if( $age < $wgRCMaxAge ) {
 140+ # Update rc_this_oldid for the entries which were current
 141+ $dbw->update( 'recentchanges',
 142+ array( /* SET */
 143+ 'rc_this_oldid' => $oldid
 144+ ), array( /* WHERE */
 145+ 'rc_namespace' => $ns,
 146+ 'rc_title' => $title,
 147+ 'rc_timestamp' => $dbw->timestamp( $lastTime )
 148+ ), $fname
 149+ );
 150+ }
145151
146152 # Update rc_cur_time
147153 $dbw->update( 'recentchanges', array( 'rc_cur_time' => $now ),
Index: trunk/phase3/includes/DefaultSettings.php
@@ -721,6 +721,10 @@
722722 # Log IP addresses in the recentchanges table
723723 $wgPutIPinRC = false;
724724
 725+# Recentchanges items are periodically purged;
 726+# entries older than this many seconds will go.
 727+$wgRCMaxAge = 7 * 24 * 3600; # our one week cutoff
 728+
725729 # RDF metadata toggles
726730 $wgEnableDublinCoreRdf = false;
727731 $wgEnableCreativeCommonsRdf = false;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r6659(bug 730) Hack at Jamesday's request to avoid trying to update old recentchan...vibber21:15, 12 December 2004
r7169* (bug 730) configurable $wgRCMaxAge; don't try to update purged RC entriesvibber03:53, 19 January 2005

Status & tagging log