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:
parent
01bc818d46
commit
dcefa16318
2
phpBB/includes/cache/driver/file.php
vendored
2
phpBB/includes/cache/driver/file.php
vendored
@ -385,6 +385,8 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
|
||||
{
|
||||
$query_result = $query_id;
|
||||
}
|
||||
|
||||
return $query_id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
2
phpBB/includes/cache/driver/memory.php
vendored
2
phpBB/includes/cache/driver/memory.php
vendored
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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'))
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
32
tests/cache/cache_test.php
vendored
32
tests/cache/cache_test.php
vendored
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user