Skip to content

Commit 35dc642

Browse files
committed
fix: missing Postgre error message
1 parent 0a45ea8 commit 35dc642

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

system/Database/BaseConnection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ public function initialize()
420420
// Connect to the database and set the connection ID
421421
$this->connID = $this->connect($this->pConnect);
422422
} catch (Throwable $e) {
423+
$this->connID = false;
423424
$connectionErrors[] = sprintf('Main connection [%s]: %s', $this->DBDriver, $e->getMessage());
424425
log_message('error', 'Error connecting to the database: ' . $e);
425426
}

system/Database/Postgre/Connection.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,19 @@ public function connect(bool $persistent = false)
8080
if ($this->connID !== false) {
8181
if ($persistent === true && pg_connection_status($this->connID) === PGSQL_CONNECTION_BAD && pg_ping($this->connID) === false
8282
) {
83-
return false;
83+
$error = pg_last_error($this->connID);
84+
85+
throw new DatabaseException($error);
8486
}
8587

8688
if (! empty($this->schema)) {
8789
$this->simpleQuery("SET search_path TO {$this->schema},public");
8890
}
8991

9092
if ($this->setClientEncoding($this->charset) === false) {
91-
return false;
93+
$error = pg_last_error($this->connID);
94+
95+
throw new DatabaseException($error);
9296
}
9397
}
9498

0 commit comments

Comments
 (0)