Defer af_throttled query to post-commit auto-commit mode

* Due to the nature of this code (a throttle) it will likely slam the DB,
  so push it after the end of the main transaction.

bug: 60600
Change-Id: I48895358deaa1b951d849eeee14c7126cfa25ec8
This commit is contained in:
Aaron Schulz 2014-01-29 15:08:19 -08:00
parent f957c3b70a
commit 9a632d04ec

View file

@ -1625,12 +1625,15 @@ class AbuseFilter {
// More than $wgAbuseFilterEmergencyDisableCount matches,
// constituting more than $emergencyDisableThreshold
// (a fraction) of last few edits. Disable it.
$method = __METHOD__;
$dbw = wfGetDB( DB_MASTER );
$dbw->update( 'abuse_filter',
array( 'af_throttled' => 1 ),
array( 'af_id' => $filter ),
__METHOD__
);
$dbw->onTransactionIdle( function() use ( $dbw, $filter, $method ) {
$dbw->update( 'abuse_filter',
array( 'af_throttled' => 1 ),
array( 'af_id' => $filter ),
$method
);
} );
}
}
}