From 0be1ffd29618602e238ebd7784baa624f1362aa2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 31 Jul 2023 16:41:34 +0200 Subject: [PATCH] [ticket/9687] Adjust queries to be compatible with postgres PHPBB3-9687 --- phpBB/includes/functions_user.php | 2 +- phpBB/phpbb/ban/type/base.php | 2 +- phpBB/phpbb/ban/type/user.php | 2 +- tests/ban/ban_manager_test.php | 8 ++++---- tests/functions_user/fixtures/delete_user.xml | 4 ++++ 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 3913b20090..c50e0d01ee 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -750,7 +750,7 @@ function user_delete($mode, $user_ids, $retain_username = true) // Delete the user_id from the banlist $sql = 'DELETE FROM ' . BANS_TABLE . ' - WHERE ban_mode = \'user\' AND ' . $db->sql_in_set('ban_item', $user_ids); + WHERE ban_mode = \'user\' AND ' . $db->sql_in_set('ban_userid', $user_ids); $db->sql_query($sql); // Delete the user_id from the session table diff --git a/phpBB/phpbb/ban/type/base.php b/phpBB/phpbb/ban/type/base.php index 92b324f9b3..84b9502dc1 100644 --- a/phpBB/phpbb/ban/type/base.php +++ b/phpBB/phpbb/ban/type/base.php @@ -115,7 +115,7 @@ abstract class base implements type_interface WHERE (ban_end >= ' . time() . " OR ban_end = 0) AND ban_mode = '{$this->get_type()}' - ORDER BY ban_item"; + ORDER BY ban_item, ban_id"; $result = $this->db->sql_query($sql); $rowset = $this->db->sql_fetchrowset($result); $this->db->sql_freeresult($result); diff --git a/phpBB/phpbb/ban/type/user.php b/phpBB/phpbb/ban/type/user.php index 7ad1195988..0971cf4cf4 100644 --- a/phpBB/phpbb/ban/type/user.php +++ b/phpBB/phpbb/ban/type/user.php @@ -140,7 +140,7 @@ class user extends base $this->banned_users = []; while ($row = $this->db->sql_fetchrow($result)) { - $ban_items[] = (int) $row['user_id']; + $ban_items[] = (string) $row['user_id']; $this->banned_users[(int) $row['user_id']] = $row['username']; } $this->db->sql_freeresult($result); diff --git a/tests/ban/ban_manager_test.php b/tests/ban/ban_manager_test.php index b8af909c7d..4034ad7966 100644 --- a/tests/ban/ban_manager_test.php +++ b/tests/ban/ban_manager_test.php @@ -225,9 +225,9 @@ class ban_manager_test extends \phpbb_session_test_case 'email', [ [ - 'ban_id' => '9', + 'ban_id' => '5', 'ban_userid' => 0, - 'ban_item' => '*@foo.bar', + 'ban_item' => 'bar@example.org', 'ban_start' => '1111', 'ban_end' => '0', 'ban_reason' => 'HAHAHA', @@ -235,9 +235,9 @@ class ban_manager_test extends \phpbb_session_test_case 'ban_mode' => 'email', ], [ - 'ban_id' => '5', + 'ban_id' => '9', 'ban_userid' => 0, - 'ban_item' => 'bar@example.org', + 'ban_item' => '*@foo.bar', 'ban_start' => '1111', 'ban_end' => '0', 'ban_reason' => 'HAHAHA', diff --git a/tests/functions_user/fixtures/delete_user.xml b/tests/functions_user/fixtures/delete_user.xml index 1727b8a783..c149a42429 100644 --- a/tests/functions_user/fixtures/delete_user.xml +++ b/tests/functions_user/fixtures/delete_user.xml @@ -38,6 +38,7 @@ ban_id + ban_useridban_modeban_itemban_start @@ -46,6 +47,7 @@ ban_reason_display 1 + 2 user 2 0 @@ -55,6 +57,7 @@ 2 + 3 user 3 0 @@ -64,6 +67,7 @@ 3 + 0 user 0 0