jenkins-bot has submitted this change and it was merged. Change subject: Fixed broken batching in PurgeOldLogIPData ......................................................................
Fixed broken batching in PurgeOldLogIPData Bug: T95382 Change-Id: I133642e5dd8e75e98e6189ad10f54dbbea648c8d --- M maintenance/purgeOldLogIPData.php 1 file changed, 18 insertions(+), 13 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/maintenance/purgeOldLogIPData.php b/maintenance/purgeOldLogIPData.php index cf8a270..b4fe74c 100644 --- a/maintenance/purgeOldLogIPData.php +++ b/maintenance/purgeOldLogIPData.php @@ -19,29 +19,34 @@ $this->output( "Purging old IP Address data from abuse_filter_log...\n" ); $dbw = wfGetDB( DB_MASTER ); + $cutoffUnix = time() - $wgAbuseFilterLogIPMaxAge; $count = 0; - while ( true ) { - $dbw->begin(); - $dbw->update( + do { + $ids = $dbw->selectFieldValues( 'abuse_filter_log', - array( 'afl_ip' => '' ), + 'afl_id', array( 'afl_ip <> ""', - "afl_timestamp < " . $dbw->addQuotes( $dbw->timestamp( time() - $wgAbuseFilterLogIPMaxAge ) ) + "afl_timestamp < " . $dbw->addQuotes( $dbw->timestamp( $cutoffUnix ) ) ), __METHOD__, array( 'LIMIT' => $this->mBatchSize ) ); - $count += $dbw->affectedRows(); - $dbw->commit(); - if ( $dbw->affectedRows() < $this->mBatchSize ) { - break; // all updated - } - $this->output( "$count\n" ); - wfWaitForSlaves(); - } + if ( $ids ) { + $dbw->update( + 'abuse_filter_log', + array( 'afl_ip' => '' ), + array( 'afl_id' => $ids ), + __METHOD__ + ); + $count += $dbw->affectedRows(); + $this->output( "$count\n" ); + + wfWaitForSlaves(); + } + } while ( count( $ids ) >= $this->mBatchSize ); $this->output( "$count rows.\n" ); -- To view, visit https://gerrit.wikimedia.org/r/202657 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I133642e5dd8e75e98e6189ad10f54dbbea648c8d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/AbuseFilter Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Gilles <gdu...@wikimedia.org> Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Se4598 <se4...@gmx.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits