diff options
-rw-r--r-- | phpBB/includes/cache/driver/file.php | 2 | ||||
-rw-r--r-- | phpBB/includes/cache/driver/memory.php | 2 | ||||
-rw-r--r-- | phpBB/includes/db/firebird.php | 2 | ||||
-rw-r--r-- | phpBB/includes/db/mssql.php | 2 | ||||
-rw-r--r-- | phpBB/includes/db/mssql_odbc.php | 2 | ||||
-rw-r--r-- | phpBB/includes/db/mssqlnative.php | 2 | ||||
-rw-r--r-- | phpBB/includes/db/mysql.php | 2 | ||||
-rw-r--r-- | phpBB/includes/db/mysqli.php | 2 | ||||
-rw-r--r-- | phpBB/includes/db/oracle.php | 2 | ||||
-rw-r--r-- | phpBB/includes/db/postgres.php | 2 | ||||
-rw-r--r-- | phpBB/includes/db/sqlite.php | 2 | ||||
-rw-r--r-- | tests/cache/cache_test.php | 32 | ||||
-rw-r--r-- | tests/mock/cache.php | 2 |
13 files changed, 45 insertions, 11 deletions
diff --git a/phpBB/includes/cache/driver/file.php b/phpBB/includes/cache/driver/file.php index da942b921c..f64a9e3ea8 100644 --- a/phpBB/includes/cache/driver/file.php +++ b/phpBB/includes/cache/driver/file.php @@ -385,6 +385,8 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base { $query_result = $query_id; } + + return $query_id; } /** diff --git a/phpBB/includes/cache/driver/memory.php b/phpBB/includes/cache/driver/memory.php index aabad2bb6c..92971c6cb2 100644 --- a/phpBB/includes/cache/driver/memory.php +++ b/phpBB/includes/cache/driver/memory.php @@ -335,6 +335,8 @@ class phpbb_cache_driver_memory extends phpbb_cache_driver_base $this->_write('sql_' . $hash, $this->sql_rowset[$query_id], $ttl); $query_result = $query_id; + + return $query_id; } /** diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php index 99deb5603e..9f9b8a1abd 100644 --- a/phpBB/includes/db/firebird.php +++ b/phpBB/includes/db/firebird.php @@ -272,7 +272,7 @@ class dbal_firebird extends dbal if ($cache_ttl) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php index d92fe27b99..bde283c3ea 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/mssql.php @@ -162,7 +162,7 @@ class dbal_mssql extends dbal if ($cache_ttl) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index 6292792a55..687bc52abc 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -181,7 +181,7 @@ class dbal_mssql_odbc extends dbal if ($cache_ttl) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php index 0d8786171a..36ff461a29 100644 --- a/phpBB/includes/db/mssqlnative.php +++ b/phpBB/includes/db/mssqlnative.php @@ -338,7 +338,7 @@ class dbal_mssqlnative extends dbal if ($cache_ttl) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index fd567af076..5b4ff86579 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -190,7 +190,7 @@ class dbal_mysql extends dbal if ($cache_ttl) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php index 26cade2ff0..1f13bd5459 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/mysqli.php @@ -196,7 +196,7 @@ class dbal_mysqli extends dbal if ($cache_ttl) { - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } } else if (defined('DEBUG_EXTRA')) diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php index e9ff2f4434..de2729e973 100644 --- a/phpBB/includes/db/oracle.php +++ b/phpBB/includes/db/oracle.php @@ -421,7 +421,7 @@ class dbal_oracle extends dbal if ($cache_ttl) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php index c35199e917..f0a4a7a7a2 100644 --- a/phpBB/includes/db/postgres.php +++ b/phpBB/includes/db/postgres.php @@ -218,7 +218,7 @@ class dbal_postgres extends dbal if ($cache_ttl) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php index 814b593f05..2cf55b07e2 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/sqlite.php @@ -135,7 +135,7 @@ class dbal_sqlite extends dbal if ($cache_ttl) { $this->open_queries[(int) $this->query_result] = $this->query_result; - $cache->sql_save($query, $this->query_result, $cache_ttl); + $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl); } else if (strpos($query, 'SELECT') === 0 && $this->query_result) { diff --git a/tests/cache/cache_test.php b/tests/cache/cache_test.php index 564bd35863..81ce9ac1aa 100644 --- a/tests/cache/cache_test.php +++ b/tests/cache/cache_test.php @@ -9,7 +9,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -class phpbb_cache_test extends phpbb_test_case +class phpbb_cache_test extends phpbb_database_test_case { private $cache_dir; @@ -18,6 +18,11 @@ class phpbb_cache_test extends phpbb_test_case $this->cache_dir = dirname(__FILE__) . '/../tmp/cache/'; } + public function getDataSet() + { + return array(); + } + protected function setUp() { if (file_exists($this->cache_dir)) @@ -67,4 +72,29 @@ class phpbb_cache_test extends phpbb_test_case 'File ACM put and get' ); } + + public function test_cache_sql() + { + $driver = new phpbb_cache_driver_file($this->cache_dir); + + global $db, $cache; + $db = $this->new_dbal(); + $cache = new phpbb_cache_service($driver); + + $sql = 'SELECT * FROM phpbb_config WHERE config_name = \'board_disable\''; + $result = $db->sql_query($sql, 300); + $first_result = $db->sql_fetchrow($result); + + $this->assertFileExists($this->cache_dir . 'sql_' . md5($sql) . '.php'); + + $sql = 'SELECT * FROM phpbb_config WHERE config_name = \'board_disable\''; + $result = $db->sql_query($sql, 300); + + $this->assertEquals($first_result, $db->sql_fetchrow($result)); + + $sql = 'SELECT * FROM phpbb_config WHERE config_name = \'version\''; + $result = $db->sql_query($sql, 300); + + $this->assertNotEquals($first_result, $db->sql_fetchrow($result)); + } } diff --git a/tests/mock/cache.php b/tests/mock/cache.php index c6d08afef0..b64c92ea89 100644 --- a/tests/mock/cache.php +++ b/tests/mock/cache.php @@ -121,7 +121,7 @@ class phpbb_mock_cache implements phpbb_cache_driver_interface public function sql_load($query) { } - public function sql_save($query, &$query_result, $ttl) + public function sql_save($query, $query_result, $ttl) { } public function sql_exists($query_id) |