diff --git a/lib/Doctrine/Export.php b/lib/Doctrine/Export.php index ab56d662..f0961045 100644 --- a/lib/Doctrine/Export.php +++ b/lib/Doctrine/Export.php @@ -1221,7 +1221,7 @@ public function exportClasses(array $classes) } } - $connection->commit(); + Doctrine_TransactionHelper::commitIfInTransaction($connection); } } diff --git a/lib/Doctrine/TransactionHelper.php b/lib/Doctrine/TransactionHelper.php new file mode 100644 index 00000000..6cc60660 --- /dev/null +++ b/lib/Doctrine/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_TransactionHelper +{ + 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