diff --git a/phpBB/phpbb/ban/type/base.php b/phpBB/phpbb/ban/type/base.php index 0419ebf380..92b324f9b3 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 ASC, ban_id ASC"; + ORDER BY ban_item"; $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 66c3f3f4de..7e01ac8bb5 100644 --- a/phpBB/phpbb/ban/type/user.php +++ b/phpBB/phpbb/ban/type/user.php @@ -80,7 +80,7 @@ class user extends base OR b.ban_end = 0) AND b.ban_userid = u.user_id AND b.ban_mode = '{$this->get_type()}' - ORDER BY username_clean ASC"; + ORDER BY u.username_clean ASC"; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { diff --git a/tests/ban/ban_manager_test.php b/tests/ban/ban_manager_test.php index 12f836fa65..de347568b2 100644 --- a/tests/ban/ban_manager_test.php +++ b/tests/ban/ban_manager_test.php @@ -276,6 +276,13 @@ class ban_manager_test extends \phpbb_session_test_case { $this->expectException($expected_exception); } + + // Fix weird sorting by postgres + if (is_array($expected) && $ban_type == 'email' && $this->db->get_sql_layer() == 'postgres') + { + $expected = array_reverse($expected); + } + $this->assertEquals($expected, $this->ban_manager->get_bans($ban_type)); }