From 98209b91ba39896fa9faaca67881f8d7e7a57bbe Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 3 Nov 2023 20:44:42 +0100 Subject: [PATCH] [ticket/17209] Add fallback for searching for roles for standard titles PHPBB3-17209 --- phpBB/phpbb/db/migration/tool/permission.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/phpBB/phpbb/db/migration/tool/permission.php b/phpBB/phpbb/db/migration/tool/permission.php index 80d64b403a..69f32fcb4c 100644 --- a/phpBB/phpbb/db/migration/tool/permission.php +++ b/phpBB/phpbb/db/migration/tool/permission.php @@ -256,6 +256,18 @@ class permission implements \phpbb\db\migration\tool\tool_interface $role_id = (int) $this->db->sql_fetchfield('role_id'); $this->db->sql_freeresult($result); + // Try falling back to searching by role description for standard role titles + if (!$role_id && preg_match('/ROLE_(?([A-Z]+_?)+)/', $role_name, $matches)) + { + $role_description = 'ROLE_DESCRIPTION_' . $matches['title']; + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_description = '" . $this->db->sql_escape($role_description) . "'"; + $result = $this->db->sql_query($sql); + $role_id = (int) $this->db->sql_fetchfield('role_id'); + $this->db->sql_freeresult($result); + } + return $role_id; }