Error: Call to a member function inTransaction() on null in <PROJECT_DIR>/vendor/codeception/module-db/src/Codeception/Lib/Driver/Db.php on line 94
The error did not occur when using Codeception 4.
Maybe it has to do with a different order of PHP internally calling __destruct() methods on objects.
I should note that the errors occur when running wp-browsers own test suite against Codeception 5 (Alpha). wp-browser extends the native Db class, but does never call __destruct() directly or set $dbh to null.
The following patch fixes that behavior:
diff --git a/src/Codeception/Lib/Driver/Db.php b/src/Codeception/Lib/Driver/Db.php
index b69017e..c83203c 100755
--- a/src/Codeception/Lib/Driver/Db.php
+++ b/src/Codeception/Lib/Driver/Db.php
@@ -91,7 +91,7 @@ class Db
public function __destruct()
{
- if ($this->dbh->inTransaction()) {
+ if ($this->dbh && $this->dbh->inTransaction()) {
$this->dbh->rollBack();
}
Error message:
The error did not occur when using Codeception 4.
Maybe it has to do with a different order of PHP internally calling
__destruct()
methods on objects.I should note that the errors occur when running wp-browsers own test suite against Codeception 5 (Alpha). wp-browser extends the native
Db
class, but does never call__destruct()
directly or set$dbh
tonull
.The following patch fixes that behavior:
Might be related: https://github.com/Codeception/Codeception/pull/5072