1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-21 08:12:17 +02:00

[ticket/10875] Return $query_id from sql_save

Have to return the $query_id from sql_save so that the results can be pulled

Updated cache test to do some basic sql cache testing.

PHPBB3-10875
This commit is contained in:
Nathan Guse 2012-08-06 16:26:55 -05:00
parent 01bc818d46
commit dcefa16318
13 changed files with 45 additions and 11 deletions

View File

@ -385,6 +385,8 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
{
$query_result = $query_id;
}
return $query_id;
}
/**

View File

@ -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;
}
/**

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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'))

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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));
}
}

View File

@ -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)