mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Merge branch 'ticket/jellydoughnut/9637' into develop-olympus
* ticket/jellydoughnut/9637: [ticket/9637] Do not cache SQL server version in all cases
This commit is contained in:
commit
2d9aa45aef
10 changed files with 52 additions and 25 deletions
|
@ -63,10 +63,19 @@ class dbal_firebird extends dbal
|
||||||
/**
|
/**
|
||||||
* Version information about used database
|
* Version information about used database
|
||||||
* @param bool $raw if true, only return the fetched sql_server_version
|
* @param bool $raw if true, only return the fetched sql_server_version
|
||||||
|
* @param bool $use_cache forced to false for Interbase
|
||||||
* @return string sql server version
|
* @return string sql server version
|
||||||
*/
|
*/
|
||||||
function sql_server_info($raw = false)
|
function sql_server_info($raw = false, $use_cache = true)
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* force $use_cache false. I didn't research why the caching code there is no caching code
|
||||||
|
* but I assume its because the IB extension provides a direct method to access it
|
||||||
|
* without a query.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$use_cache = false;
|
||||||
|
|
||||||
if ($this->service_handle !== false && function_exists('ibase_server_info'))
|
if ($this->service_handle !== false && function_exists('ibase_server_info'))
|
||||||
{
|
{
|
||||||
return @ibase_server_info($this->service_handle, IBASE_SVC_SERVER_VERSION);
|
return @ibase_server_info($this->service_handle, IBASE_SVC_SERVER_VERSION);
|
||||||
|
|
|
@ -65,13 +65,14 @@ class dbal_mssql extends dbal
|
||||||
/**
|
/**
|
||||||
* Version information about used database
|
* Version information about used database
|
||||||
* @param bool $raw if true, only return the fetched sql_server_version
|
* @param bool $raw if true, only return the fetched sql_server_version
|
||||||
|
* @param bool $use_cache If true, it is safe to retrieve the value from the cache
|
||||||
* @return string sql server version
|
* @return string sql server version
|
||||||
*/
|
*/
|
||||||
function sql_server_info($raw = false)
|
function sql_server_info($raw = false, $use_cache = true)
|
||||||
{
|
{
|
||||||
global $cache;
|
global $cache;
|
||||||
|
|
||||||
if (empty($cache) || ($this->sql_server_version = $cache->get('mssql_version')) === false)
|
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssql_version')) === false)
|
||||||
{
|
{
|
||||||
$result_id = @mssql_query("SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SERVERPROPERTY('edition')", $this->db_connect_id);
|
$result_id = @mssql_query("SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SERVERPROPERTY('edition')", $this->db_connect_id);
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ class dbal_mssql extends dbal
|
||||||
|
|
||||||
$this->sql_server_version = ($row) ? trim(implode(' ', $row)) : 0;
|
$this->sql_server_version = ($row) ? trim(implode(' ', $row)) : 0;
|
||||||
|
|
||||||
if (!empty($cache))
|
if (!empty($cache) && $use_cache)
|
||||||
{
|
{
|
||||||
$cache->put('mssql_version', $this->sql_server_version);
|
$cache->put('mssql_version', $this->sql_server_version);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,13 +76,14 @@ class dbal_mssql_odbc extends dbal
|
||||||
/**
|
/**
|
||||||
* Version information about used database
|
* Version information about used database
|
||||||
* @param bool $raw if true, only return the fetched sql_server_version
|
* @param bool $raw if true, only return the fetched sql_server_version
|
||||||
|
* @param bool $use_cache If true, it is safe to retrieve the value from the cache
|
||||||
* @return string sql server version
|
* @return string sql server version
|
||||||
*/
|
*/
|
||||||
function sql_server_info($raw = false)
|
function sql_server_info($raw = false, $use_cache = true)
|
||||||
{
|
{
|
||||||
global $cache;
|
global $cache;
|
||||||
|
|
||||||
if (empty($cache) || ($this->sql_server_version = $cache->get('mssqlodbc_version')) === false)
|
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssqlodbc_version')) === false)
|
||||||
{
|
{
|
||||||
$result_id = @odbc_exec($this->db_connect_id, "SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SERVERPROPERTY('edition')");
|
$result_id = @odbc_exec($this->db_connect_id, "SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SERVERPROPERTY('edition')");
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@ class dbal_mssql_odbc extends dbal
|
||||||
|
|
||||||
$this->sql_server_version = ($row) ? trim(implode(' ', $row)) : 0;
|
$this->sql_server_version = ($row) ? trim(implode(' ', $row)) : 0;
|
||||||
|
|
||||||
if (!empty($cache))
|
if (!empty($cache) && $use_cache)
|
||||||
{
|
{
|
||||||
$cache->put('mssqlodbc_version', $this->sql_server_version);
|
$cache->put('mssqlodbc_version', $this->sql_server_version);
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,18 +232,19 @@ class dbal_mssqlnative extends dbal
|
||||||
/**
|
/**
|
||||||
* Version information about used database
|
* Version information about used database
|
||||||
* @param bool $raw if true, only return the fetched sql_server_version
|
* @param bool $raw if true, only return the fetched sql_server_version
|
||||||
|
* @param bool $use_cache If true, it is safe to retrieve the value from the cache
|
||||||
* @return string sql server version
|
* @return string sql server version
|
||||||
*/
|
*/
|
||||||
function sql_server_info($raw = false)
|
function sql_server_info($raw = false, $use_cache = true)
|
||||||
{
|
{
|
||||||
global $cache;
|
global $cache;
|
||||||
|
|
||||||
if (empty($cache) || ($this->sql_server_version = $cache->get('mssql_version')) === false)
|
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssql_version')) === false)
|
||||||
{
|
{
|
||||||
$arr_server_info = sqlsrv_server_info($this->db_connect_id);
|
$arr_server_info = sqlsrv_server_info($this->db_connect_id);
|
||||||
$this->sql_server_version = $arr_server_info['SQLServerVersion'];
|
$this->sql_server_version = $arr_server_info['SQLServerVersion'];
|
||||||
|
|
||||||
if (!empty($cache))
|
if (!empty($cache) && $use_cache)
|
||||||
{
|
{
|
||||||
$cache->put('mssql_version', $this->sql_server_version);
|
$cache->put('mssql_version', $this->sql_server_version);
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,13 +96,14 @@ class dbal_mysql extends dbal
|
||||||
/**
|
/**
|
||||||
* Version information about used database
|
* Version information about used database
|
||||||
* @param bool $raw if true, only return the fetched sql_server_version
|
* @param bool $raw if true, only return the fetched sql_server_version
|
||||||
|
* @param bool $use_cache If true, it is safe to retrieve the value from the cache
|
||||||
* @return string sql server version
|
* @return string sql server version
|
||||||
*/
|
*/
|
||||||
function sql_server_info($raw = false)
|
function sql_server_info($raw = false, $use_cache = true)
|
||||||
{
|
{
|
||||||
global $cache;
|
global $cache;
|
||||||
|
|
||||||
if (empty($cache) || ($this->sql_server_version = $cache->get('mysql_version')) === false)
|
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mysql_version')) === false)
|
||||||
{
|
{
|
||||||
$result = @mysql_query('SELECT VERSION() AS version', $this->db_connect_id);
|
$result = @mysql_query('SELECT VERSION() AS version', $this->db_connect_id);
|
||||||
$row = @mysql_fetch_assoc($result);
|
$row = @mysql_fetch_assoc($result);
|
||||||
|
@ -110,7 +111,7 @@ class dbal_mysql extends dbal
|
||||||
|
|
||||||
$this->sql_server_version = $row['version'];
|
$this->sql_server_version = $row['version'];
|
||||||
|
|
||||||
if (!empty($cache))
|
if (!empty($cache) && $use_cache)
|
||||||
{
|
{
|
||||||
$cache->put('mysql_version', $this->sql_server_version);
|
$cache->put('mysql_version', $this->sql_server_version);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,14 +80,14 @@ class dbal_mysqli extends dbal
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version information about used database
|
* Version information about used database
|
||||||
* @param bool $raw if true, only return the fetched sql_server_version
|
* @param bool $use_cache If true, it is safe to retrieve the value from the cache
|
||||||
* @return string sql server version
|
* @return string sql server version
|
||||||
*/
|
*/
|
||||||
function sql_server_info($raw = false)
|
function sql_server_info($raw = false, $use_cache = true)
|
||||||
{
|
{
|
||||||
global $cache;
|
global $cache;
|
||||||
|
|
||||||
if (empty($cache) || ($this->sql_server_version = $cache->get('mysqli_version')) === false)
|
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mysqli_version')) === false)
|
||||||
{
|
{
|
||||||
$result = @mysqli_query($this->db_connect_id, 'SELECT VERSION() AS version');
|
$result = @mysqli_query($this->db_connect_id, 'SELECT VERSION() AS version');
|
||||||
$row = @mysqli_fetch_assoc($result);
|
$row = @mysqli_fetch_assoc($result);
|
||||||
|
@ -95,7 +95,7 @@ class dbal_mysqli extends dbal
|
||||||
|
|
||||||
$this->sql_server_version = $row['version'];
|
$this->sql_server_version = $row['version'];
|
||||||
|
|
||||||
if (!empty($cache))
|
if (!empty($cache) && $use_cache)
|
||||||
{
|
{
|
||||||
$cache->put('mysqli_version', $this->sql_server_version);
|
$cache->put('mysqli_version', $this->sql_server_version);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,10 +56,18 @@ class dbal_oracle extends dbal
|
||||||
/**
|
/**
|
||||||
* Version information about used database
|
* Version information about used database
|
||||||
* @param bool $raw if true, only return the fetched sql_server_version
|
* @param bool $raw if true, only return the fetched sql_server_version
|
||||||
|
* @param bool $use_cache forced to false for Oracle
|
||||||
* @return string sql server version
|
* @return string sql server version
|
||||||
*/
|
*/
|
||||||
function sql_server_info($raw = false)
|
function sql_server_info($raw = false, $use_cache = true)
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* force $use_cache false. I didn't research why the caching code below is commented out
|
||||||
|
* but I assume its because the Oracle extension provides a direct method to access it
|
||||||
|
* without a query.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$use_cache = false;
|
||||||
/*
|
/*
|
||||||
global $cache;
|
global $cache;
|
||||||
|
|
||||||
|
|
|
@ -108,13 +108,14 @@ class dbal_postgres extends dbal
|
||||||
/**
|
/**
|
||||||
* Version information about used database
|
* Version information about used database
|
||||||
* @param bool $raw if true, only return the fetched sql_server_version
|
* @param bool $raw if true, only return the fetched sql_server_version
|
||||||
|
* @param bool $use_cache If true, it is safe to retrieve the value from the cache
|
||||||
* @return string sql server version
|
* @return string sql server version
|
||||||
*/
|
*/
|
||||||
function sql_server_info($raw = false)
|
function sql_server_info($raw = false, $use_cache = true)
|
||||||
{
|
{
|
||||||
global $cache;
|
global $cache;
|
||||||
|
|
||||||
if (empty($cache) || ($this->sql_server_version = $cache->get('pgsql_version')) === false)
|
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('pgsql_version')) === false)
|
||||||
{
|
{
|
||||||
$query_id = @pg_query($this->db_connect_id, 'SELECT VERSION() AS version');
|
$query_id = @pg_query($this->db_connect_id, 'SELECT VERSION() AS version');
|
||||||
$row = @pg_fetch_assoc($query_id, null);
|
$row = @pg_fetch_assoc($query_id, null);
|
||||||
|
@ -122,7 +123,7 @@ class dbal_postgres extends dbal
|
||||||
|
|
||||||
$this->sql_server_version = (!empty($row['version'])) ? trim(substr($row['version'], 10)) : 0;
|
$this->sql_server_version = (!empty($row['version'])) ? trim(substr($row['version'], 10)) : 0;
|
||||||
|
|
||||||
if (!empty($cache))
|
if (!empty($cache) && $use_cache)
|
||||||
{
|
{
|
||||||
$cache->put('pgsql_version', $this->sql_server_version);
|
$cache->put('pgsql_version', $this->sql_server_version);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,20 +50,25 @@ class dbal_sqlite extends dbal
|
||||||
/**
|
/**
|
||||||
* Version information about used database
|
* Version information about used database
|
||||||
* @param bool $raw if true, only return the fetched sql_server_version
|
* @param bool $raw if true, only return the fetched sql_server_version
|
||||||
|
* @param bool $use_cache if true, it is safe to retrieve the stored value from the cache
|
||||||
* @return string sql server version
|
* @return string sql server version
|
||||||
*/
|
*/
|
||||||
function sql_server_info($raw = false)
|
function sql_server_info($raw = false, $use_cache = true)
|
||||||
{
|
{
|
||||||
global $cache;
|
global $cache;
|
||||||
|
|
||||||
if (empty($cache) || ($this->sql_server_version = $cache->get('sqlite_version')) === false)
|
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('sqlite_version')) === false)
|
||||||
{
|
{
|
||||||
$result = @sqlite_query('SELECT sqlite_version() AS version', $this->db_connect_id);
|
$result = @sqlite_query('SELECT sqlite_version() AS version', $this->db_connect_id);
|
||||||
$row = @sqlite_fetch_array($result, SQLITE_ASSOC);
|
$row = @sqlite_fetch_array($result, SQLITE_ASSOC);
|
||||||
|
|
||||||
$this->sql_server_version = (!empty($row['version'])) ? $row['version'] : 0;
|
$this->sql_server_version = (!empty($row['version'])) ? $row['version'] : 0;
|
||||||
|
|
||||||
|
if (!empty($cache) && $use_cache)
|
||||||
|
{
|
||||||
$cache->put('sqlite_version', $this->sql_server_version);
|
$cache->put('sqlite_version', $this->sql_server_version);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ($raw) ? $this->sql_server_version : 'SQLite ' . $this->sql_server_version;
|
return ($raw) ? $this->sql_server_version : 'SQLite ' . $this->sql_server_version;
|
||||||
}
|
}
|
||||||
|
|
|
@ -685,7 +685,7 @@ class install_convert extends module
|
||||||
// Thanks MySQL, for silently converting...
|
// Thanks MySQL, for silently converting...
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
case 'mysql4':
|
case 'mysql4':
|
||||||
if (version_compare($src_db->sql_server_info(true), '4.1.3', '>='))
|
if (version_compare($src_db->sql_server_info(true, false), '4.1.3', '>='))
|
||||||
{
|
{
|
||||||
$convert->mysql_convert = true;
|
$convert->mysql_convert = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue