1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-10 02:36:38 +02:00

Merge pull request #6266 from rxu/ticket/16840-master

[ticket/16840] Add more PHP 8.x builds to tests matrix
This commit is contained in:
Marc Alexander
2021-08-16 23:07:14 +02:00
4 changed files with 35 additions and 15 deletions

View File

@@ -207,14 +207,16 @@ class postgres extends \phpbb\db\driver\driver
return false;
}
$safe_query_id = $this->clean_query_id($this->query_result);
if ($cache && $cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
$this->open_queries[$safe_query_id] = $this->query_result;
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
$this->open_queries[$safe_query_id] = $this->query_result;
}
}
else if ($this->debug_sql_explain)
@@ -555,6 +557,15 @@ class postgres extends \phpbb\db\driver\driver
*/
private function clean_query_id($query_id)
{
return is_resource($query_id) ? (int) $query_id : $query_id;
// As of PHP 8.1 PgSQL functions accept/return \PgSQL\* objects instead of "pgsql *" resources
// Attempting to cast object to int will throw error, hence correctly handle all cases
if (is_resource($query_id))
{
return function_exists('get_resource_id') ? get_resource_id($query_id) : (int) $query_id;
}
else
{
return is_object($query_id) ? spl_object_id($query_id) : $query_id;
}
}
}