From eed92e766fed98cb6204dbfe8442334577314ee8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 21 Aug 2023 18:46:41 +0200 Subject: [PATCH] [ticket/17176] Do not always create a new connection in database tests PHPBB3-17176 --- phpBB/phpbb/db/driver/postgres.php | 4 ++-- tests/test_framework/phpbb_database_test_case.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/db/driver/postgres.php b/phpBB/phpbb/db/driver/postgres.php index 1f695acb83..0289901ea9 100644 --- a/phpBB/phpbb/db/driver/postgres.php +++ b/phpBB/phpbb/db/driver/postgres.php @@ -431,8 +431,8 @@ class postgres extends \phpbb\db\driver\driver */ protected function _sql_close(): bool { - // Released resources are already closed, return true in this case - if (!$this->db_connect_id instanceof \PgSql\Connection) + // Skip if connection is already closed or not persistent + if (!$this->persistency || !$this->db_connect_id instanceof \PgSql\Connection) { return true; } diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 0c0317fe10..98626865b0 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -305,7 +305,7 @@ abstract class phpbb_database_test_case extends TestCase /** @var \phpbb\db\driver\driver_interface $db */ $db = new $config['dbms'](); - $db->sql_connect($config['dbhost'], $config['dbuser'], $config['dbpasswd'], $config['dbname'], $config['dbport'], false, true); + $db->sql_connect($config['dbhost'], $config['dbuser'], $config['dbpasswd'], $config['dbname'], $config['dbport']); $this->db_connections[] = $db;