Skip to content

Commit 4ebd33a

Browse files
committed
fix: getVersion() for OCI8 driver when no connection is established
1 parent d8be763 commit 4ebd33a

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

system/Database/OCI8/Connection.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,14 @@ public function getVersion(): string
193193
return $this->dataCache['version'];
194194
}
195195

196-
if (! $this->connID || ($versionString = oci_server_version($this->connID)) === false) {
196+
if ($this->connID === false) {
197+
$this->initialize();
198+
}
199+
200+
if (($versionString = oci_server_version($this->connID)) === false) {
197201
return '';
198202
}
203+
199204
if (preg_match('#Release\s(\d+(?:\.\d+)+)#', $versionString, $match)) {
200205
return $this->dataCache['version'] = $match[1];
201206
}

tests/system/Database/Live/GetVersionTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ final class GetVersionTest extends CIUnitTestCase
2929

3030
public function testGetVersion(): void
3131
{
32+
if ($this->db->DBDriver === 'MySQLi') {
33+
$this->db->mysqli = false;
34+
}
35+
36+
$this->db->connID = false;
37+
3238
$version = $this->db->getVersion();
3339

3440
$this->assertMatchesRegularExpression('/\A\d+(\.\d+)*\z/', $version);

user_guide_src/source/changelogs/v4.6.1.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Bugs Fixed
3232

3333
- **CURLRequest:** Fixed an issue where multiple header sections appeared in the CURL response body during multiple redirects from the target server.
3434
- **Cors:** Fixed a bug in the Cors filter that caused the appropriate headers to not be added when another filter returned a response object in the ``before`` filter.
35+
- **Database:** Fixed a bug in the ``OCI8`` driver where ``getVersion()`` returned an empty string when the database connection was not yet established.
3536

3637
See the repo's
3738
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_

0 commit comments

Comments
 (0)