Skip to content

Commit 4c6e4ec

Browse files
committed
Fix PostgreSQL getVersion() logic
1 parent 42b174f commit 4c6e4ec

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

phpstan-baseline.neon.dist

-5
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ parameters:
6565
count: 3
6666
path: system/Database/MySQLi/PreparedQuery.php
6767

68-
-
69-
message: "#^Strict comparison using \\=\\=\\= between array<string, int|string|null> and false will always evaluate to false\\.$#"
70-
count: 1
71-
path: system/Database/Postgre/Connection.php
72-
7368
-
7469
message: "#^Access to an undefined property CodeIgniter\\\\Database\\\\BaseConnection\\:\\:\\$schema\\.$#"
7570
count: 2

system/Database/Postgre/Connection.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,14 @@ public function getVersion(): string
128128
return $this->dataCache['version'];
129129
}
130130

131-
if (! $this->connID || ($pgVersion = pg_version($this->connID)) === false) {
131+
if (! $this->connID) {
132132
$this->initialize();
133133
}
134134

135-
return isset($pgVersion['server']) ? $this->dataCache['version'] = $pgVersion['server'] : false;
135+
$pgVersion = pg_version($this->connID);
136+
$this->dataCache['version'] = $pgVersion['server'] ?? '';
137+
138+
return $this->dataCache['version'];
136139
}
137140

138141
/**

0 commit comments

Comments
 (0)