From 1990ee2d4c7bad6f45a1f9fc9e473d3b3b66c132 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 14 Aug 2008 18:38:41 +0000 Subject: Correctly return results for nested cached queries (Bug #31445 - Patch by faw) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8758 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/db/mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/db/mysql.php') diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 2d689f86f9..5c8d08b19d 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -183,7 +183,7 @@ class dbal_mysql extends dbal return false; } - return ($this->query_result) ? $this->query_result : false; + return ($this->query_result !== false) ? $this->query_result : false; } /** -- cgit v1.2.1 From e81eb70aedd6105904854a5ce2233f4fe14eae80 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Tue, 2 Sep 2008 13:27:37 +0000 Subject: Refine fix for #31445 originally committed in r8758 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8809 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/db/mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/db/mysql.php') diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 5c8d08b19d..edeaf7aa73 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -183,7 +183,7 @@ class dbal_mysql extends dbal return false; } - return ($this->query_result !== false) ? $this->query_result : false; + return $this->query_result; } /** -- cgit v1.2.1 From 2fcd96ca72741bdfb36c24a0af9dd8230b5a828f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 4 Sep 2008 12:01:47 +0000 Subject: Ok, story real database server info, as well as caching it Store it on installation too - allows us to check the db version used on installation and used currently to warn the user about incompatibilities git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8814 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/db/mysql.php | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) (limited to 'phpBB/includes/db/mysql.php') diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index edeaf7aa73..31b2850776 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -29,7 +29,6 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); */ class dbal_mysql extends dbal { - var $mysql_version; var $multi_insert = true; /** @@ -52,13 +51,14 @@ class dbal_mysql extends dbal if (@mysql_select_db($this->dbname, $this->db_connect_id)) { // Determine what version we are using and if it natively supports UNICODE - $this->mysql_version = mysql_get_server_info($this->db_connect_id); + $this->sql_server_info(); - if (version_compare($this->mysql_version, '4.1.3', '>=')) + if (version_compare($this->sql_server_version, '4.1.3', '>=')) { @mysql_query("SET NAMES 'utf8'", $this->db_connect_id); + // enforce strict mode on databases that support it - if (version_compare($this->mysql_version, '5.0.2', '>=')) + if (version_compare($this->sql_server_version, '5.0.2', '>=')) { $result = @mysql_query('SELECT @@session.sql_mode AS sql_mode', $this->db_connect_id); $row = @mysql_fetch_assoc($result); @@ -83,7 +83,7 @@ class dbal_mysql extends dbal @mysql_query("SET SESSION sql_mode='{$mode}'", $this->db_connect_id); } } - else if (version_compare($this->mysql_version, '4.0.0', '<')) + else if (version_compare($this->sql_server_version, '4.0.0', '<')) { $this->sql_layer = 'mysql'; } @@ -97,10 +97,28 @@ class dbal_mysql extends dbal /** * Version information about used database + * @param bool $raw if true, only return the fetched sql_server_version + * @return string sql server version */ - function sql_server_info() + function sql_server_info($raw = false) { - return 'MySQL ' . $this->mysql_version; + global $cache; + + if (empty($cache) || ($this->sql_server_version = $cache->get('mysql_version')) === false) + { + $result = @mysql_query('SELECT VERSION() AS version', $this->db_connect_id); + $row = @mysql_fetch_assoc($result); + @mysql_free_result($result); + + $this->sql_server_version = $row['version']; + + if (!empty($cache)) + { + $cache->put('mysql_version', $this->sql_server_version); + } + } + + return ($raw) ? $this->sql_server_version : 'MySQL ' . $this->sql_server_version; } /** @@ -367,13 +385,9 @@ class dbal_mysql extends dbal if ($test_prof === null) { $test_prof = false; - if (strpos($this->mysql_version, 'community') !== false) + if (version_compare($this->sql_server_info(true), '5.0.37', '>=') && version_compare($this->sql_server_info(true), '5.1', '<')) { - $ver = substr($this->mysql_version, 0, strpos($this->mysql_version, '-')); - if (version_compare($ver, '5.0.37', '>=') && version_compare($ver, '5.1', '<')) - { - $test_prof = true; - } + $test_prof = true; } } -- cgit v1.2.1 From 7a11fdbb644dc467ede71ca09d205d5ec2ef7ae1 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 4 Sep 2008 13:37:01 +0000 Subject: direct calls git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8815 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/db/mysql.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/db/mysql.php') diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 31b2850776..080f3d541a 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -51,14 +51,12 @@ class dbal_mysql extends dbal if (@mysql_select_db($this->dbname, $this->db_connect_id)) { // Determine what version we are using and if it natively supports UNICODE - $this->sql_server_info(); - - if (version_compare($this->sql_server_version, '4.1.3', '>=')) + if (version_compare($this->sql_server_info(true), '4.1.3', '>=')) { @mysql_query("SET NAMES 'utf8'", $this->db_connect_id); // enforce strict mode on databases that support it - if (version_compare($this->sql_server_version, '5.0.2', '>=')) + if (version_compare($this->sql_server_info(true), '5.0.2', '>=')) { $result = @mysql_query('SELECT @@session.sql_mode AS sql_mode', $this->db_connect_id); $row = @mysql_fetch_assoc($result); @@ -83,7 +81,7 @@ class dbal_mysql extends dbal @mysql_query("SET SESSION sql_mode='{$mode}'", $this->db_connect_id); } } - else if (version_compare($this->sql_server_version, '4.0.0', '<')) + else if (version_compare($this->sql_server_info(true), '4.0.0', '<')) { $this->sql_layer = 'mysql'; } -- cgit v1.2.1 From 272cde82514dbaa547e584b9c59824f6fc4133c8 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 16 Mar 2009 17:08:28 +0000 Subject: Set connection encoding for MySQL versions 4.1.0 to 4.1.2. This may fix some conversion issues with special characters. (Bug #41805) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9378 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/db/mysql.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/db/mysql.php') diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 080f3d541a..c03b38708c 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -51,7 +51,7 @@ class dbal_mysql extends dbal if (@mysql_select_db($this->dbname, $this->db_connect_id)) { // Determine what version we are using and if it natively supports UNICODE - if (version_compare($this->sql_server_info(true), '4.1.3', '>=')) + if (version_compare($this->sql_server_info(true), '4.1.0', '>=')) { @mysql_query("SET NAMES 'utf8'", $this->db_connect_id); @@ -341,7 +341,7 @@ class dbal_mysql extends dbal return $data; } - + /** * return sql error array * @access private -- cgit v1.2.1 From 409dfe52565b850c9a60aa360e9df44bd73f6ce6 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 23 Dec 2009 15:07:52 +0000 Subject: Fix Bug #55785 - Correct call to mysql_pconnect(). Note: As pointed out by gn#36, phpBB doesn't use persistent connections at all. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10375 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/db/mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/db/mysql.php') diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index c03b38708c..0487dfa6d2 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -44,7 +44,7 @@ class dbal_mysql extends dbal $this->sql_layer = 'mysql4'; - $this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $sqlpassword, $new_link) : @mysql_connect($this->server, $this->user, $sqlpassword, $new_link); + $this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $sqlpassword) : @mysql_connect($this->server, $this->user, $sqlpassword, $new_link); if ($this->db_connect_id && $this->dbname != '') { -- cgit v1.2.1