Skip to content

Commit fd01f33

Browse files
committed
fix: SQLSRV getVersion() when no connection is established
1 parent b0b891a commit fd01f33

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Diff for: system/Database/SQLSRV/Connection.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,15 @@ public function getVersion(): string
561561
return $this->dataCache['version'];
562562
}
563563

564-
if (! $this->connID || ($info = sqlsrv_server_info($this->connID)) === []) {
564+
if (! $this->connID) {
565565
$this->initialize();
566566
}
567567

568-
return isset($info['SQLServerVersion']) ? $this->dataCache['version'] = $info['SQLServerVersion'] : false;
568+
if (($info = sqlsrv_server_info($this->connID)) === []) {
569+
return '';
570+
}
571+
572+
return isset($info['SQLServerVersion']) ? $this->dataCache['version'] = $info['SQLServerVersion'] : '';
569573
}
570574

571575
/**

Diff for: user_guide_src/source/changelogs/v4.6.1.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +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.
35+
- **Database:** Fixed a bug in the ``OCI8`` and ``SQLSRV`` drivers where ``getVersion()`` returned an empty string when the database connection was not yet established.
3636

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

0 commit comments

Comments
 (0)