From 1c055d3e6fbee2ee6d7cd5b58c1f2f37db8dccda Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Sat, 13 May 2023 23:42:58 -0500 Subject: [PATCH] Disable emulate prepares in DB --- lib/DbConnection.php | 3 +-- scripts/process-pending-payments | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/DbConnection.php b/lib/DbConnection.php index bcf1fe4e..57ec9ee4 100644 --- a/lib/DbConnection.php +++ b/lib/DbConnection.php @@ -42,8 +42,7 @@ class DbConnection{ $connectionString .= ';dbname=' . $defaultDatabase; } - // Have to use ATTR_EMULATE_PREPARES = true, otherwise transactions don't work for some reason. - $params = [\PDO::ATTR_EMULATE_PREPARES => true, \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, \PDO::ATTR_PERSISTENT => false]; + $params = [\PDO::ATTR_EMULATE_PREPARES => false, \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, \PDO::ATTR_PERSISTENT => false]; if($forceUtf8){ $params[\PDO::MYSQL_ATTR_INIT_COMMAND] = 'set names utf8mb4 collate utf8mb4_unicode_ci;'; diff --git a/scripts/process-pending-payments b/scripts/process-pending-payments index a64bd0fa..87c57869 100755 --- a/scripts/process-pending-payments +++ b/scripts/process-pending-payments @@ -44,20 +44,22 @@ $faPassword = get_cfg_var('se.secrets.fractured_atlas.password'); // 946554ca-ffc0-4259-bcc6-be6c844fbbdc Regular donation, patrons, private, recurring // 416608c6-cbf5-4153-8956-cb9051bb849e Regular donation, patrons, public, one time, in memory of -$pendingPayments = Db::Query(' - start transaction; +Db::Query('start transaction'); +$pendingPayments = Db::Query(' SELECT * from PendingPayments - where ProcessedOn is null; - - UPDATE PendingPayments - set ProcessedOn = utc_timestamp() - where ProcessedOn is null; - - commit; + where ProcessedOn is null '); +Db::Query(' + UPDATE PendingPayments + set ProcessedOn = utc_timestamp() + where ProcessedOn is null + '); + +Db::Query('commit'); + if(sizeof($pendingPayments) == 0){ // Don't start the very slow Selenium driver if we have nothing to process exit();