From 274c426583d91b20a1e39968b2e20969ef83cd1d Mon Sep 17 00:00:00 2001 From: Gabor de Mooij Date: Fri, 17 Mar 2023 23:39:19 +0100 Subject: [PATCH] Add fluid transaction check. Closes #922. --- RedBeanPHP/Facade.php | 1 + testing/RedUNIT/Blackhole/Misc.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/RedBeanPHP/Facade.php b/RedBeanPHP/Facade.php index 0054ebdf..00fd36e1 100644 --- a/RedBeanPHP/Facade.php +++ b/RedBeanPHP/Facade.php @@ -381,6 +381,7 @@ public static function useISNULLConditions( $mode ) */ public static function transaction( $callback ) { + if ( !self::$allowFluidTransactions && !self::$redbean->isFrozen() ) return FALSE; return Transaction::transaction( self::$adapter, $callback ); } diff --git a/testing/RedUNIT/Blackhole/Misc.php b/testing/RedUNIT/Blackhole/Misc.php index 8330481f..1c00bf54 100644 --- a/testing/RedUNIT/Blackhole/Misc.php +++ b/testing/RedUNIT/Blackhole/Misc.php @@ -396,13 +396,14 @@ public function testTransactionInFacade() pass(); } asrt( R::count( 'bean' ), 1 ); - R::freeze( FALSE ); try { R::transaction( 'nope' ); fail(); } catch (\Exception $e ) { pass(); } + R::freeze( FALSE ); + asrt(R::transaction( 'nope' ), FALSE); testpack( 'Test Camelcase 2 underscore' ); $names = array( 'oneACLRoute' => 'one_acl_route',