Skip to content

Commit bc05b84

Browse files
committed
Fix version() for Oracle DB drivers
1 parent 27ba5e6 commit bc05b84

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

system/database/drivers/oci8/oci8_driver.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,16 @@ public function version()
252252
return $this->data_cache['version'];
253253
}
254254

255-
if ( ! $this->conn_id OR ($version = oci_server_version($this->conn_id)) === FALSE)
255+
if ( ! $this->conn_id OR ($version_string = oci_server_version($this->conn_id)) === FALSE)
256256
{
257257
return FALSE;
258258
}
259+
elseif (preg_match('#Release\s(\d+(?:\.\d+)+)#', $version_string, $match))
260+
{
261+
return $this->data_cache['version'] = $match[1];
262+
}
259263

260-
return $this->data_cache['version'] = $version;
264+
return FALSE;
261265
}
262266

263267
// --------------------------------------------------------------------

system/database/drivers/pdo/subdrivers/pdo_oci_driver.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,29 @@ public function __construct($params)
129129

130130
// --------------------------------------------------------------------
131131

132+
/**
133+
* Database version number
134+
*
135+
* @return string
136+
*/
137+
public function version()
138+
{
139+
if (isset($this->data_cache['version']))
140+
{
141+
return $this->data_cache['version'];
142+
}
143+
144+
$version_string = parent::version();
145+
if (preg_match('#Release\s(?<version>\d+(?:\.\d+)+)#', $version_string, $match))
146+
{
147+
return $this->data_cache['version'] = $match[1];
148+
}
149+
150+
return FALSE;
151+
}
152+
153+
// --------------------------------------------------------------------
154+
132155
/**
133156
* Show table query
134157
*

user_guide_src/source/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Bug fixes for 3.0.4
2727
- Fixed a bug (#4039) - :doc:`Session Library <libraries/sessions>` could generate multiple (redundant) warnings in case of a read failure with the 'files' driver, due to a bug in PHP.
2828
- Fixed a bug where :doc:`Session Library <libraries/sessions>` didn't have proper error handling on PHP 5 (due to a PHP bug).
2929
- Fixed a bug (#4312) - :doc:`Form Validation Library <libraries/form_validation>` didn't provide error feedback for failed validation on empty requests.
30+
- Fixed a bug where :doc:`Database <database/index>` method `version()` returned banner text instead of only the version number with the 'oci8' and 'pdo/oci' drivers.
3031

3132
Version 3.0.3
3233
=============

0 commit comments

Comments
 (0)