File tree Expand file tree Collapse file tree
tests/system/Database/Live Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -184,7 +184,12 @@ public static function cleanupForWorkerMode(): void
184184 log_message ('error ' , "Uncommitted transaction detected in database group ' {$ group }'. Transactions must be completed before request ends. " );
185185
186186 while ($ connection ->transDepth > 0 ) {
187- $ connection ->transRollback ();
187+ try {
188+ $ connection ->transRollback ();
189+ } catch (\Throwable $ e ) {
190+ log_message ('critical ' , $ e ->getMessage ());
191+ break ;
192+ }
188193 }
189194 }
190195
Original file line number Diff line number Diff line change 1818use CodeIgniter \Test \CIUnitTestCase ;
1919use CodeIgniter \Test \DatabaseTestTrait ;
2020use PHPUnit \Framework \Attributes \Group ;
21+ use RuntimeException ;
2122
2223/**
2324 * @internal
@@ -48,6 +49,22 @@ public function testCleanupForWorkerMode(): void
4849 $ this ->assertNotFalse ($ this ->getPrivateProperty ($ conn , 'connID ' ));
4950 }
5051
52+ public function testCleanupForWorkerModeLogsRollbackCallbackException (): void
53+ {
54+ $ conn = Config::connect ();
55+ $ this ->assertInstanceOf (BaseConnection::class, $ conn );
56+
57+ $ conn ->transStart ();
58+ $ conn ->afterRollback (static function (): void {
59+ throw new RuntimeException ('Rollback callback failed. ' );
60+ });
61+
62+ Config::cleanupForWorkerMode ();
63+
64+ $ this ->assertSame (0 , $ conn ->transDepth );
65+ $ this ->assertLogged ('critical ' , 'Rollback callback failed. ' );
66+ }
67+
5168 public function testReconnectForWorkerMode (): void
5269 {
5370 $ conn = Config::connect ();
You can’t perform that action at this time.
0 commit comments