Skip to content

Commit 87f8256

Browse files
committed
fix(database): satisfy Psalm for OCI8 prepared exceptions
Signed-off-by: memleakd <121398829+memleakd@users.noreply.github.com>
1 parent 0e9ad55 commit 87f8256

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

system/Database/OCI8/PreparedQuery.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace CodeIgniter\Database\OCI8;
1515

1616
use CodeIgniter\Database\BasePreparedQuery;
17+
use CodeIgniter\Database\Exceptions\DatabaseException;
1718
use CodeIgniter\Exceptions\BadMethodCallException;
1819
use ErrorException;
1920
use OCILob;
@@ -89,10 +90,10 @@ public function _execute(array $data): bool
8990
try {
9091
$result = oci_execute($this->statement, $this->db->commitMode);
9192
} catch (ErrorException $e) {
92-
$this->setDatabaseExceptionFromStatement($e);
93+
$databaseException = $this->setDatabaseExceptionFromStatement($e);
9394

9495
if ($this->db->DBDebug) {
95-
throw $this->databaseException;
96+
throw $databaseException;
9697
}
9798

9899
return false;
@@ -103,10 +104,10 @@ public function _execute(array $data): bool
103104
}
104105

105106
if ($result === false) {
106-
$this->setDatabaseExceptionFromStatement();
107+
$databaseException = $this->setDatabaseExceptionFromStatement();
107108

108109
if ($this->db->DBDebug) {
109-
throw $this->databaseException;
110+
throw $databaseException;
110111
}
111112
}
112113

@@ -138,12 +139,14 @@ protected function _close(): bool
138139
/**
139140
* Captures the native OCI statement error for shared database exception classification.
140141
*/
141-
private function setDatabaseExceptionFromStatement(?ErrorException $previous = null): void
142+
private function setDatabaseExceptionFromStatement(?ErrorException $previous = null): DatabaseException
142143
{
143144
$error = oci_error($this->statement);
144145
$this->errorCode = $error['code'] ?? 0;
145146
$this->errorString = $error['message'] ?? $previous?->getMessage() ?? '';
146147
$this->databaseException = $this->db->createDatabaseException($this->errorString, $this->errorCode, $previous);
148+
149+
return $this->databaseException;
147150
}
148151

149152
/**

0 commit comments

Comments
 (0)