From 3635b82351c60aee01ee4ad2f9523a6b61f15acb Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 24 May 2019 14:27:52 -0400 Subject: [PATCH] Skip wrapping v4 api requests in a transaction Transactions aren't a bad thing and we probably want to revisit this but for now I'm disabling it becuase it's broken, as seen in api_v3_ActivityTest. I think the problem is with the onApiException event not being dispatched because api4 doesn't go through Kernel->runSafe, so transactions aren't being rolled back when they should. --- Civi/API/Subscriber/TransactionSubscriber.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Civi/API/Subscriber/TransactionSubscriber.php b/Civi/API/Subscriber/TransactionSubscriber.php index 4f7b0c64d8..5f784320ca 100644 --- a/Civi/API/Subscriber/TransactionSubscriber.php +++ b/Civi/API/Subscriber/TransactionSubscriber.php @@ -79,6 +79,9 @@ class TransactionSubscriber implements EventSubscriberInterface { * @return bool */ public function isTransactional($apiProvider, $apiRequest) { + if ($apiRequest['version'] == 4) { + return FALSE; + } if ($this->isForceRollback($apiProvider, $apiRequest)) { return TRUE; } @@ -98,6 +101,9 @@ class TransactionSubscriber implements EventSubscriberInterface { * @return bool */ public function isForceRollback($apiProvider, $apiRequest) { + if ($apiRequest['version'] == 4) { + return FALSE; + } // FIXME: When APIv3 uses better parsing, only one check will be needed. if (isset($apiRequest['params']['options']['force_rollback'])) { return \CRM_Utils_String::strtobool($apiRequest['params']['options']['force_rollback']); -- 2.25.1