Skip to content

Commit

Permalink
Fix PostgreSQL getVersion() logic
Browse files Browse the repository at this point in the history
  • Loading branch information
marekmosna committed May 12, 2023
1 parent 42b174f commit efbf68c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 0 additions & 5 deletions phpstan-baseline.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ parameters:
count: 3
path: system/Database/MySQLi/PreparedQuery.php

-
message: "#^Strict comparison using \\=\\=\\= between array<string, int|string|null> and false will always evaluate to false\\.$#"
count: 1
path: system/Database/Postgre/Connection.php

-
message: "#^Access to an undefined property CodeIgniter\\\\Database\\\\BaseConnection\\:\\:\\$schema\\.$#"
count: 2
Expand Down
10 changes: 8 additions & 2 deletions system/Database/Postgre/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,17 @@ public function getVersion(): string
return $this->dataCache['version'];
}

if (! $this->connID || ($pgVersion = pg_version($this->connID)) === false) {
if (! $this->connID) {
$this->initialize();
}

return isset($pgVersion['server']) ? $this->dataCache['version'] = $pgVersion['server'] : false;
$pgVersion = pg_version($this->connID);

if (! isset($pgVersion['server'])) {
return 'PostgreSQL 7.4 or lower';
}

return $this->dataCache['version'] = $pgVersion['server'];
}

/**
Expand Down

0 comments on commit efbf68c

Please sign in to comment.