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 |
1 | 39 | + native |
Property changes on: trunk/extensions/CheckUser/maintenance |
___________________________________________________________________ |
Added: bugtraq:number |
2 | 40 | + true |
Index: trunk/extensions/CheckUser/CheckUser.hooks.php |
— | — | @@ -58,11 +58,8 @@ |
59 | 59 | |
60 | 60 | # Every 100th edit, prune the checkuser changes table. |
61 | 61 | if ( 0 == mt_rand( 0, 99 ) ) { |
62 | | - # Periodically flush old entries from the recentchanges table. |
63 | 62 | $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__ ); |
67 | 64 | } |
68 | 65 | |
69 | 66 | return true; |