Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX PDO in PHP 8 #10378

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/ORM/Connect/PDOConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PDO;
use PDOStatement;
use InvalidArgumentException;
use PDOException;

/**
* PDO driver database connector
Expand Down Expand Up @@ -109,10 +110,15 @@ public function getOrPrepareStatement($sql)
}

// Generate new statement
$statement = $this->pdoConnection->prepare(
$sql,
[PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY]
);
try {
$statement = $this->pdoConnection->prepare(
$sql,
[PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY]
);
} catch (PDOException $e) {
$statement = false;
$this->databaseError($e->getMessage(), E_USER_ERROR, $sql);
}

// Wrap in a PDOStatementHandle, to cache column metadata
$statementHandle = ($statement === false) ? false : new PDOStatementHandle($statement);
Expand Down Expand Up @@ -557,8 +563,13 @@ public function transactionRollback($savepoint = null)
}
}

// Note: $this->inTransaction may not match the 'in-transaction' state in PDO
$this->inTransaction = false;
return $this->pdoConnection->rollBack();
if ($this->pdoConnection->inTransaction()) {
return $this->pdoConnection->rollBack();
}
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
// return false because it did not rollback.
return false;
}

public function transactionDepth()
Expand Down