1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-25 20:44:01 +01:00

[ticket/12387] Use the hash as query_id for caching

PHPBB3-12387
This commit is contained in:
Tristan Darricau 2014-06-22 22:49:33 +02:00
parent 50f4bea610
commit d039f56af0
2 changed files with 9 additions and 10 deletions

View File

@ -396,13 +396,13 @@ class file extends \phpbb\cache\driver\base
{ {
// Remove extra spaces and tabs // Remove extra spaces and tabs
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query); $query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
$query_id = md5($query);
if (($rowset = $this->_read('sql_' . md5($query))) === false) if (($rowset = $this->_read('sql_' . $query_id)) === false)
{ {
return false; return false;
} }
$query_id = sizeof($this->sql_rowset);
$this->sql_rowset[$query_id] = $rowset; $this->sql_rowset[$query_id] = $rowset;
$this->sql_row_pointer[$query_id] = 0; $this->sql_row_pointer[$query_id] = 0;
@ -417,7 +417,7 @@ class file extends \phpbb\cache\driver\base
// Remove extra spaces and tabs // Remove extra spaces and tabs
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query); $query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
$query_id = sizeof($this->sql_rowset); $query_id = md5($query);
$this->sql_rowset[$query_id] = array(); $this->sql_rowset[$query_id] = array();
$this->sql_row_pointer[$query_id] = 0; $this->sql_row_pointer[$query_id] = 0;
@ -427,7 +427,7 @@ class file extends \phpbb\cache\driver\base
} }
$db->sql_freeresult($query_result); $db->sql_freeresult($query_result);
if ($this->_write('sql_' . md5($query), $this->sql_rowset[$query_id], $ttl + time(), $query)) if ($this->_write('sql_' . $query_id, $this->sql_rowset[$query_id], $ttl + time(), $query))
{ {
return $query_id; return $query_id;
} }

View File

@ -266,9 +266,9 @@ abstract class memory extends \phpbb\cache\driver\base
{ {
// Remove extra spaces and tabs // Remove extra spaces and tabs
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query); $query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
$query_id = sizeof($this->sql_rowset); $query_id = md5($query);
if (($result = $this->_read('sql_' . md5($query))) === false) if (($result = $this->_read('sql_' . $query_id)) === false)
{ {
return false; return false;
} }
@ -286,7 +286,7 @@ abstract class memory extends \phpbb\cache\driver\base
{ {
// Remove extra spaces and tabs // Remove extra spaces and tabs
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query); $query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
$hash = md5($query); $query_id = md5($query);
// determine which tables this query belongs to // determine which tables this query belongs to
// Some queries use backticks, namely the get_database_size() query // Some queries use backticks, namely the get_database_size() query
@ -315,14 +315,13 @@ abstract class memory extends \phpbb\cache\driver\base
$temp = array(); $temp = array();
} }
$temp[$hash] = true; $temp[$query_id] = true;
// This must never expire // This must never expire
$this->_write('sql_' . $table_name, $temp, 0); $this->_write('sql_' . $table_name, $temp, 0);
} }
// store them in the right place // store them in the right place
$query_id = sizeof($this->sql_rowset);
$this->sql_rowset[$query_id] = array(); $this->sql_rowset[$query_id] = array();
$this->sql_row_pointer[$query_id] = 0; $this->sql_row_pointer[$query_id] = 0;
@ -332,7 +331,7 @@ abstract class memory extends \phpbb\cache\driver\base
} }
$db->sql_freeresult($query_result); $db->sql_freeresult($query_result);
$this->_write('sql_' . $hash, $this->sql_rowset[$query_id], $ttl); $this->_write('sql_' . $query_id, $this->sql_rowset[$query_id], $ttl);
return $query_id; return $query_id;
} }