mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-21 16:22:22 +02:00
commit
dca9057559
4
phpBB/includes/cache/driver/file.php
vendored
4
phpBB/includes/cache/driver/file.php
vendored
@ -364,7 +364,7 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
|
||||
/**
|
||||
* Save sql query
|
||||
*/
|
||||
function sql_save($query, &$query_result, $ttl)
|
||||
function sql_save($query, $query_result, $ttl)
|
||||
{
|
||||
global $db;
|
||||
|
||||
@ -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/interface.php
vendored
2
phpBB/includes/cache/driver/interface.php
vendored
@ -75,7 +75,7 @@ interface phpbb_cache_driver_interface
|
||||
/**
|
||||
* Save sql query
|
||||
*/
|
||||
public function sql_save($query, &$query_result, $ttl);
|
||||
public function sql_save($query, $query_result, $ttl);
|
||||
|
||||
/**
|
||||
* Ceck if a given sql query exist in cache
|
||||
|
4
phpBB/includes/cache/driver/memory.php
vendored
4
phpBB/includes/cache/driver/memory.php
vendored
@ -280,7 +280,7 @@ class phpbb_cache_driver_memory extends phpbb_cache_driver_base
|
||||
/**
|
||||
* Save sql query
|
||||
*/
|
||||
function sql_save($query, &$query_result, $ttl)
|
||||
function sql_save($query, $query_result, $ttl)
|
||||
{
|
||||
global $db;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
2
phpBB/includes/cache/driver/null.php
vendored
2
phpBB/includes/cache/driver/null.php
vendored
@ -107,7 +107,7 @@ class phpbb_cache_driver_null extends phpbb_cache_driver_base
|
||||
/**
|
||||
* Save sql query
|
||||
*/
|
||||
function sql_save($query, &$query_result, $ttl)
|
||||
function sql_save($query, $query_result, $ttl)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ class dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
@ -256,7 +256,7 @@ class dbal
|
||||
$this->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
||||
if (!is_object($query_id) && isset($cache->sql_rowset[$query_id]))
|
||||
if (!is_object($query_id) && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchfield($query_id, $field);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
@ -332,7 +332,7 @@ class dbal_firebird extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
@ -398,7 +398,7 @@ class dbal_firebird extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
@ -234,7 +234,7 @@ class dbal_mssql extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
@ -271,7 +271,7 @@ class dbal_mssql extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
@ -310,7 +310,7 @@ class dbal_mssql extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
@ -254,7 +254,7 @@ class dbal_mssql_odbc extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
@ -295,7 +295,7 @@ class dbal_mssql_odbc extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
@ -418,7 +418,7 @@ class dbal_mssqlnative extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
@ -478,7 +478,7 @@ class dbal_mssqlnative extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
@ -249,7 +249,7 @@ class dbal_mysql extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
@ -270,7 +270,7 @@ class dbal_mysql extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
@ -298,7 +298,7 @@ class dbal_mysql extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
@ -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'))
|
||||
@ -251,7 +251,7 @@ class dbal_mysqli extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (!is_object($query_id) && isset($cache->sql_rowset[$query_id]))
|
||||
if (!is_object($query_id) && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
@ -278,7 +278,7 @@ class dbal_mysqli extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (!is_object($query_id) && isset($cache->sql_rowset[$query_id]))
|
||||
if (!is_object($query_id) && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
@ -306,7 +306,7 @@ class dbal_mysqli extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (!is_object($query_id) && isset($cache->sql_rowset[$query_id]))
|
||||
if (!is_object($query_id) && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
@ -473,7 +473,7 @@ class dbal_oracle extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
@ -525,7 +525,7 @@ class dbal_oracle extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
@ -594,7 +594,7 @@ class dbal_oracle extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
@ -285,7 +285,7 @@ class dbal_postgres extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
@ -306,7 +306,7 @@ class dbal_postgres extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
@ -355,7 +355,7 @@ class dbal_postgres extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
@ -193,7 +193,7 @@ class dbal_sqlite extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
@ -214,7 +214,7 @@ class dbal_sqlite extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
@ -242,7 +242,7 @@ class dbal_sqlite extends dbal
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if (isset($cache->sql_rowset[$query_id]))
|
||||
if ($cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ class install_update extends module
|
||||
|
||||
// We are directly within an update. To make sure our update list is correct we check its status.
|
||||
$update_list = ($request->variable('check_again', false, false, phpbb_request_interface::POST)) ? false : $cache->get('_update_list');
|
||||
$modified = ($update_list !== false) ? @filemtime($cache->cache_dir . 'data_update_list.' . $phpEx) : 0;
|
||||
$modified = ($update_list !== false) ? @filemtime($cache->get_driver()->cache_dir . 'data_update_list.' . $phpEx) : 0;
|
||||
|
||||
// Make sure the list is up-to-date
|
||||
if ($update_list !== false)
|
||||
|
41
tests/cache/cache_test.php
vendored
41
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,8 +18,15 @@ class phpbb_cache_test extends phpbb_test_case
|
||||
$this->cache_dir = dirname(__FILE__) . '/../tmp/cache/';
|
||||
}
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (file_exists($this->cache_dir))
|
||||
{
|
||||
// cache directory possibly left after aborted
|
||||
@ -35,6 +42,8 @@ class phpbb_cache_test extends phpbb_test_case
|
||||
{
|
||||
$this->remove_cache_dir();
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
private function create_cache_dir()
|
||||
@ -67,4 +76,34 @@ 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 = 'foo'";
|
||||
$result = $db->sql_query($sql, 300);
|
||||
$first_result = $db->sql_fetchrow($result);
|
||||
|
||||
$this->assertFileExists($this->cache_dir . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)) . '.php');
|
||||
|
||||
$sql = "SELECT * FROM phpbb_config
|
||||
WHERE config_name = 'foo'";
|
||||
$result = $db->sql_query($sql, 300);
|
||||
|
||||
$this->assertEquals($first_result, $db->sql_fetchrow($result));
|
||||
|
||||
$sql = "SELECT * FROM phpbb_config
|
||||
WHERE config_name = 'bar'";
|
||||
$result = $db->sql_query($sql, 300);
|
||||
|
||||
$this->assertNotEquals($first_result, $db->sql_fetchrow($result));
|
||||
|
||||
$db->sql_close();
|
||||
}
|
||||
}
|
||||
|
18
tests/cache/fixtures/config.xml
vendored
Normal file
18
tests/cache/fixtures/config.xml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_config">
|
||||
<column>config_name</column>
|
||||
<column>config_value</column>
|
||||
<column>is_dynamic</column>
|
||||
<row>
|
||||
<value>foo</value>
|
||||
<value>23</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>bar</value>
|
||||
<value>42</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
@ -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