r99187 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99186‎ | r99187 | r99188 >
Date:03:28, 7 October 2011
Author:aaron
Status:ok (Comments)
Tags:
Comment:
* Added script to manually clear out old data (per $wgCUDMaxAge)
* Cleaned up DELETE statement to use database wrapper more
Modified paths:
  • /trunk/extensions/CheckUser/CheckUser.hooks.php (modified) (history)
  • /trunk/extensions/CheckUser/maintenance (added) (history)
  • /trunk/extensions/CheckUser/maintenance/purgeOldData.php (added) (history)

Diff [purge]

Index: trunk/extensions/CheckUser/maintenance/purgeOldData.php
@@ -0,0 +1,37 @@
 2+<?php
 3+if ( getenv( 'MW_INSTALL_PATH' ) ) {
 4+ $IP = getenv( 'MW_INSTALL_PATH' );
 5+} else {
 6+ $IP = dirname(__FILE__).'/../../..';
 7+}
 8+require_once( "$IP/maintenance/Maintenance.php" );
 9+
 10+class PurgeOldIPAddressData extends Maintenance {
 11+ public function __construct() {
 12+ parent::__construct();
 13+ $this->mDescription = "Purge old IP data in CheckUser and RecentChanges";
 14+ }
 15+
 16+ public function execute() {
 17+ global $wgCUDMaxAge, $wgRCMaxAge, $wgPutIPinRC;
 18+
 19+ $dbw = wfGetDB( DB_MASTER );
 20+
 21+ $this->output( "Purging data from cu_changes..." );
 22+ $cutoff = $dbw->timestamp( time() - $wgCUDMaxAge );
 23+ $dbw->delete( 'cu_changes', array( "cuc_timestamp < '{$cutoff}'" ), __METHOD__ );
 24+ $this->output( $dbw->affectedRows() . " rows.\n" );
 25+
 26+ if ( $wgPutIPinRC ) {
 27+ $this->output( "Purging data from recentchanges..." );
 28+ $cutoff = $dbw->timestamp( time() - $wgRCMaxAge );
 29+ $dbw->delete( 'recentchanges', array( "rc_timestamp < '{$cutoff}'" ), __METHOD__ );
 30+ $this->output( $dbw->affectedRows() . " rows.\n" );
 31+ }
 32+
 33+ $this->output( "Done.\n" );
 34+ }
 35+}
 36+
 37+$maintClass = "PurgeOldIPAddressData";
 38+require_once( RUN_MAINTENANCE_IF_MAIN );
Property changes on: trunk/extensions/CheckUser/maintenance/purgeOldData.php
___________________________________________________________________
Added: svn:eol-style
139 + native
Property changes on: trunk/extensions/CheckUser/maintenance
___________________________________________________________________
Added: bugtraq:number
240 + true
Index: trunk/extensions/CheckUser/CheckUser.hooks.php
@@ -58,11 +58,8 @@
5959
6060 # Every 100th edit, prune the checkuser changes table.
6161 if ( 0 == mt_rand( 0, 99 ) ) {
62 - # Periodically flush old entries from the recentchanges table.
6362 $cutoff = $dbw->timestamp( time() - $wgCUDMaxAge );
64 - $recentchanges = $dbw->tableName( 'cu_changes' );
65 - $sql = "DELETE FROM $recentchanges WHERE cuc_timestamp < '{$cutoff}'";
66 - $dbw->query( $sql, __METHOD__ );
 63+ $dbw->delete( 'cu_changes', array( "cuc_timestamp < '{$cutoff}'" ), __METHOD__ );
6764 }
6865
6966 return true;

Follow-up revisions

RevisionCommit summaryAuthorDate
r99193FU r99187:...aaron04:52, 7 October 2011
r100488MFT r99187,r99193 - 'Added script to manually clear out old data (per $wgCUDM...aaron02:15, 22 October 2011
r100491MFT r99187, r99193reedy02:35, 22 October 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   03:31, 7 October 2011

More to come on this.

#Comment by Aaron Schulz (talk | contribs)   04:53, 7 October 2011

Status & tagging log