mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-15 05:14:28 +02:00
[ticket/16740] Add method for ensuring resource is not passed to cache
PHPBB3-16740
This commit is contained in:
parent
1d22f001e6
commit
645e662b11
@ -277,9 +277,10 @@ class postgres extends \phpbb\db\driver\driver
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
$safe_query_id = $this->clean_query_id($query_id);
|
||||
if ($cache && $cache->sql_exists($safe_query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
return $cache->sql_fetchrow($safe_query_id);
|
||||
}
|
||||
|
||||
return ($query_id) ? pg_fetch_assoc($query_id, null) : false;
|
||||
@ -297,14 +298,47 @@ class postgres extends \phpbb\db\driver\driver
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
$safe_query_id = $this->clean_query_id($query_id);
|
||||
if ($cache && $cache->sql_exists($safe_query_id))
|
||||
{
|
||||
return $cache->sql_rowseek($rownum, $query_id);
|
||||
return $cache->sql_rowseek($rownum, $safe_query_id);
|
||||
}
|
||||
|
||||
return ($query_id) ? @pg_result_seek($query_id, $rownum) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_fetchfield($field, $rownum = false, $query_id = false)
|
||||
{
|
||||
global $cache;
|
||||
|
||||
if ($query_id === false)
|
||||
{
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($query_id)
|
||||
{
|
||||
if ($rownum !== false)
|
||||
{
|
||||
$this->sql_rowseek($rownum, $query_id);
|
||||
}
|
||||
|
||||
$safe_query_id = $this->clean_query_id($query_id);
|
||||
if ($cache && !is_object($query_id) && $cache->sql_exists($safe_query_id))
|
||||
{
|
||||
return $cache->sql_fetchfield($safe_query_id, $field);
|
||||
}
|
||||
|
||||
$row = $this->sql_fetchrow($query_id);
|
||||
return (isset($row[$field])) ? $row[$field] : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ -346,14 +380,15 @@ class postgres extends \phpbb\db\driver\driver
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
|
||||
$safe_query_id = $this->clean_query_id($query_id);
|
||||
if ($cache && !is_object($query_id) && $cache->sql_exists($safe_query_id))
|
||||
{
|
||||
return $cache->sql_freeresult($query_id);
|
||||
return $cache->sql_freeresult($safe_query_id);
|
||||
}
|
||||
|
||||
if (isset($this->open_queries[(int) $query_id]))
|
||||
if (isset($this->open_queries[(int) $safe_query_id]))
|
||||
{
|
||||
unset($this->open_queries[(int) $query_id]);
|
||||
unset($this->open_queries[(int) $safe_query_id]);
|
||||
return pg_free_result($query_id);
|
||||
}
|
||||
|
||||
@ -505,4 +540,16 @@ class postgres extends \phpbb\db\driver\driver
|
||||
{
|
||||
return '"' . $msg . '"';
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure query ID can be used by cache
|
||||
*
|
||||
* @param resource|int|string $query_id Mixed type query id
|
||||
*
|
||||
* @return int|string Query id in string or integer format
|
||||
*/
|
||||
private function clean_query_id($query_id)
|
||||
{
|
||||
return is_resource($query_id) ? (int) $query_id : $query_id;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user