1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Merge branch 'prep-release-3.3.4' into 3.3.x

This commit is contained in:
Marc Alexander
2021-05-01 21:51:16 +02:00
15 changed files with 158 additions and 23 deletions

View File

@@ -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[$safe_query_id]))
{
unset($this->open_queries[(int) $query_id]);
unset($this->open_queries[$safe_query_id]);
return pg_free_result($query_id);
}
@@ -431,6 +466,11 @@ class postgres extends \phpbb\db\driver\driver
*/
function _sql_close()
{
// Released resources are already closed, return true in this case
if (!is_resource($this->db_connect_id))
{
return true;
}
return @pg_close($this->db_connect_id);
}
@@ -505,4 +545,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;
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\db\migration\data\v33x;
class v334 extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
return version_compare($this->config['version'], '3.3.4', '>=');
}
static public function depends_on()
{
return [
'\phpbb\db\migration\data\v33x\v334rc1',
];
}
public function update_data()
{
return [
['config.update', ['version', '3.3.4']],
];
}
}

View File

@@ -96,6 +96,24 @@ class postgres extends tools
return $tables;
}
/**
* {@inheritDoc}
*/
function sql_table_exists($table_name)
{
$sql = "SELECT CAST(EXISTS(
SELECT FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name = '" . $this->db->sql_escape($table_name) . "'
) AS INTEGER)";
$result = $this->db->sql_query_limit($sql, 1);
$row = $this->db->sql_fetchrow($result);
$table_exists = (booL) $row['exists'];
$this->db->sql_freeresult($result);
return $table_exists;
}
/**
* {@inheritDoc}
*/