From 43b1aed39bd7d0579350be5f372be3a34b903320 Mon Sep 17 00:00:00 2001 From: Kyle McGrogan Date: Fri, 5 Apr 2024 11:34:31 -0400 Subject: [PATCH 1/2] Update the export command to use a PHP8-safe PDO transaction commit path --- lib/Doctrine/Export.php | 2 +- .../Transaction/TransactionHelper.php | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 lib/Doctrine/Transaction/TransactionHelper.php diff --git a/lib/Doctrine/Export.php b/lib/Doctrine/Export.php index ab56d6620..e14be577e 100644 --- a/lib/Doctrine/Export.php +++ b/lib/Doctrine/Export.php @@ -1221,7 +1221,7 @@ public function exportClasses(array $classes) } } - $connection->commit(); + Doctrine_Transaction_Helper::commitIfInTransaction($connection); } } diff --git a/lib/Doctrine/Transaction/TransactionHelper.php b/lib/Doctrine/Transaction/TransactionHelper.php new file mode 100644 index 000000000..d88e6ec67 --- /dev/null +++ b/lib/Doctrine/Transaction/TransactionHelper.php @@ -0,0 +1,47 @@ +. + */ + +/** + * Doctrine_Transaction_Helper + * + * @package Doctrine + * @subpackage Transaction + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 1.4 + * @version $Revision$ + * @author Kyle McGrogan + */ +final class Doctrine_Transaction_Helper +{ + public static function commitIfInTransaction(Doctrine_Connection $connection): void + { + $handler = $connection->getDbh(); + + // Attempt to commit while no transaction is running results in exception since PHP 8 + pdo_mysql combination + if ($handler instanceof PDO && !$handler->inTransaction()) { + return; + } + + $connection->commit(); + } +} \ No newline at end of file From d420b2a3cda415f558c26897b295d27ece3982b2 Mon Sep 17 00:00:00 2001 From: Kyle McGrogan Date: Mon, 8 Apr 2024 11:35:02 -0400 Subject: [PATCH 2/2] Relocate helper class so it's found by the autoloader --- lib/Doctrine/Export.php | 2 +- lib/Doctrine/{Transaction => }/TransactionHelper.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename lib/Doctrine/{Transaction => }/TransactionHelper.php (97%) diff --git a/lib/Doctrine/Export.php b/lib/Doctrine/Export.php index e14be577e..f09610451 100644 --- a/lib/Doctrine/Export.php +++ b/lib/Doctrine/Export.php @@ -1221,7 +1221,7 @@ public function exportClasses(array $classes) } } - Doctrine_Transaction_Helper::commitIfInTransaction($connection); + Doctrine_TransactionHelper::commitIfInTransaction($connection); } } diff --git a/lib/Doctrine/Transaction/TransactionHelper.php b/lib/Doctrine/TransactionHelper.php similarity index 97% rename from lib/Doctrine/Transaction/TransactionHelper.php rename to lib/Doctrine/TransactionHelper.php index d88e6ec67..6cc606606 100644 --- a/lib/Doctrine/Transaction/TransactionHelper.php +++ b/lib/Doctrine/TransactionHelper.php @@ -31,7 +31,7 @@ * @version $Revision$ * @author Kyle McGrogan */ -final class Doctrine_Transaction_Helper +final class Doctrine_TransactionHelper { public static function commitIfInTransaction(Doctrine_Connection $connection): void {