Skip to content

Commit 43b1aed

Browse files
Kyle McGroganthePanz
authored andcommitted
Update the export command to use a PHP8-safe PDO transaction commit path
1 parent a552724 commit 43b1aed

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

lib/Doctrine/Export.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ public function exportClasses(array $classes)
12211221
}
12221222
}
12231223

1224-
$connection->commit();
1224+
Doctrine_Transaction_Helper::commitIfInTransaction($connection);
12251225
}
12261226
}
12271227

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
/*
4+
* $Id$
5+
*
6+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
7+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
8+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
9+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
10+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
11+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
12+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
13+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
14+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
16+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17+
*
18+
* This software consists of voluntary contributions made by many individuals
19+
* and is licensed under the LGPL. For more information, see
20+
* <http://www.doctrine-project.org>.
21+
*/
22+
23+
/**
24+
* Doctrine_Transaction_Helper
25+
*
26+
* @package Doctrine
27+
* @subpackage Transaction
28+
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
29+
* @link www.doctrine-project.org
30+
* @since 1.4
31+
* @version $Revision$
32+
* @author Kyle McGrogan <[email protected]>
33+
*/
34+
final class Doctrine_Transaction_Helper
35+
{
36+
public static function commitIfInTransaction(Doctrine_Connection $connection): void
37+
{
38+
$handler = $connection->getDbh();
39+
40+
// Attempt to commit while no transaction is running results in exception since PHP 8 + pdo_mysql combination
41+
if ($handler instanceof PDO && !$handler->inTransaction()) {
42+
return;
43+
}
44+
45+
$connection->commit();
46+
}
47+
}

0 commit comments

Comments
 (0)