forked from leftypol/leftypol
anti-bot.php: use transactions
This commit is contained in:
parent
73bc23a4c7
commit
b459551ccb
1 changed files with 45 additions and 37 deletions
|
@ -190,18 +190,21 @@ class AntiBot {
|
|||
}
|
||||
}
|
||||
|
||||
function _create_antibot($board, $thread) {
|
||||
function _create_antibot($pdo, $board, $thread) {
|
||||
global $config, $purged_old_antispam;
|
||||
|
||||
$antibot = new AntiBot(array($board, $thread));
|
||||
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
|
||||
// Delete old expired antispam, skipping those with NULL expiration timestamps (infinite lifetime).
|
||||
if (!isset($purged_old_antispam) && $config['auto_maintenance']) {
|
||||
$purged_old_antispam = true;
|
||||
purge_old_antispam();
|
||||
}
|
||||
|
||||
retry_on_deadlock(4, function() use($thread, $board, $config) {
|
||||
retry_on_deadlock(4, function() use($config, $board, $thread) {
|
||||
// Keep the now invalid timestamps around for a bit to enable users to post if they're still on an old version of
|
||||
// the HTML page.
|
||||
// By virtue of existing, we know that we're making a new version of the page, and the user from now on may just reload.
|
||||
|
@ -239,6 +242,11 @@ function _create_antibot($board, $thread) {
|
|||
error_log('Multiple deadlocks on _create_antibot while inserting, skipping');
|
||||
}
|
||||
}
|
||||
} catch (\PDOException $e) {
|
||||
$pdo->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
$pdo->commit();
|
||||
|
||||
return $antibot;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue