Skip to content

Commit

Permalink
Merge pull request phpbb#6373 from marc1706/ticket/16973
Browse files Browse the repository at this point in the history
[ticket/16973] Use actual role ids for comparison of orphaned roles
  • Loading branch information
marc1706 committed Mar 17, 2022
2 parents 028340e + 91f2f2c commit 34f27a1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions phpBB/phpbb/db/migration/data/v33x/remove_orphaned_roles.php
Expand Up @@ -30,13 +30,17 @@ public function update_data()
public function acl_remove_orphaned_roles()
{
$role_ids = [];
$auth_role_ids = [];

$sql = 'SELECT auth_role_id
FROM ' . ACL_GROUPS_TABLE . '
WHERE auth_role_id <> 0
AND forum_id = 0';
$result = $this->db->sql_query($sql);
$auth_role_ids = array_keys($this->db->sql_fetchrowset($result));
while ($row = $this->db->sql_fetchrow($result))
{
$auth_role_ids[] = $row['auth_role_id'];
}
$this->db->sql_freeresult($result);

if (count($auth_role_ids))
Expand All @@ -45,7 +49,10 @@ public function acl_remove_orphaned_roles()
FROM ' . ACL_ROLES_TABLE . '
WHERE ' . $this->db->sql_in_set('role_id', $auth_role_ids);
$result = $this->db->sql_query($sql);
$role_ids = array_keys($this->db->sql_fetchrowset($result));
while ($row = $this->db->sql_fetchrow($result))
{
$role_ids[] = $row['role_id'];
}
$this->db->sql_freeresult($result);
}

Expand Down

0 comments on commit 34f27a1

Please sign in to comment.