Skip to content

Commit

Permalink
restore pre-PHP 8 semantics for PDO::commit/rollBack after implicit c…
Browse files Browse the repository at this point in the history
…ommit
  • Loading branch information
RocketMan committed Nov 20, 2023
1 parent f8ceb5d commit d58d1f4
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions engine/DBO.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zookeeper Online
*
* @author Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2022 Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2023 Jim Mason <[email protected]>
* @link https://zookeeper.ibinx.com/
* @license GPL-3.0
*
Expand Down Expand Up @@ -126,7 +126,8 @@ public function executeAndFetchAll($style=\PDO::FETCH_ASSOC) {

/**
* PDO decorator that logs errors, as well as provides pre-MySQL 5.7.5
* semantics for GROUP BY queries
* semantics for GROUP BY queries, and pre-PHP 8 semantics for commit/rollBack
* after implicit commit
*/
class BasePDO {
private const LIBRARY_TABLES = [
Expand Down Expand Up @@ -178,6 +179,20 @@ public function __call($method, $args) {
return $ret;
}

public function commit() {
// restore pre-PHP 8 semantics after implicit commit
// see https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.pdo-mysql
return $this->delegate->inTransaction() ?
$this->delegate->commit() : true;
}

public function rollBack() {
// restore pre-PHP 8 semantics after implicit commit
// see https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.pdo-mysql
return $this->delegate->inTransaction() ?
$this->delegate->rollBack() : true;
}

public function prepare($stmt, $options = []) {
// disable ONLY_FULL_GROUP_BY for pre-MySQL 5.7.5 legacy behaviour
// see https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html
Expand Down

0 comments on commit d58d1f4

Please sign in to comment.