From e50f69187f21e29a12512880e0c69f2876e84aa1 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 20 Dec 2012 04:35:30 -0500 Subject: [ticket/11037] Eliminate global $db usage in cache drivers. The only time $db is needed in cache drivers is to navigate the result set in sql_save. Pass it as a parameter in that function. PHPBB3-11037 --- phpBB/includes/db/driver/mysqli.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/db/driver/mysqli.php') diff --git a/phpBB/includes/db/driver/mysqli.php b/phpBB/includes/db/driver/mysqli.php index be28a95715..4f45c5781c 100644 --- a/phpBB/includes/db/driver/mysqli.php +++ b/phpBB/includes/db/driver/mysqli.php @@ -201,7 +201,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver if ($cache_ttl) { - $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); } } else if (defined('DEBUG')) -- cgit v1.2.1 From c8c6eb46ec6eefe0e58aebcd44f4c69f5df4b065 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 2 Jan 2013 14:36:14 -0500 Subject: [ticket/11305] Check for $cache being null before using it in db drivers. There is no reason why db drivers must have a cache to work. They query the database, that part works without caches. PHPBB3-11305 --- phpBB/includes/db/driver/mysqli.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/db/driver/mysqli.php') diff --git a/phpBB/includes/db/driver/mysqli.php b/phpBB/includes/db/driver/mysqli.php index 4f45c5781c..7448bf1670 100644 --- a/phpBB/includes/db/driver/mysqli.php +++ b/phpBB/includes/db/driver/mysqli.php @@ -184,7 +184,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver $this->sql_report('start', $query); } - $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false; + $this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false; $this->sql_add_num_queries($this->query_result); if ($this->query_result === false) @@ -199,7 +199,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver $this->sql_report('stop', $query); } - if ($cache_ttl) + if ($cache && $cache_ttl) { $this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl); } @@ -256,7 +256,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver $query_id = $this->query_result; } - if (!is_object($query_id) && $cache->sql_exists($query_id)) + if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) { return $cache->sql_fetchrow($query_id); } @@ -283,7 +283,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver $query_id = $this->query_result; } - if (!is_object($query_id) && $cache->sql_exists($query_id)) + if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) { return $cache->sql_rowseek($rownum, $query_id); } @@ -311,7 +311,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver $query_id = $this->query_result; } - if (!is_object($query_id) && $cache->sql_exists($query_id)) + if ($cache && !is_object($query_id) && $cache->sql_exists($query_id)) { return $cache->sql_freeresult($query_id); } -- cgit v1.2.1