Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-83347

user role problem

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.1.13
    • Roles / Access
    • None
    • MOODLE_401_STABLE

      I found a problem with this query from lib/accesslib.php function get_roles_with_cap_in_context:
        $sql = "SELECT rc.id, rc.roleid, rc.permission, ctx.depth
                    FROM {role_capabilities} rc
                    JOIN {context} ctx ON ctx.id = rc.contextid
                    JOIN {capabilities} cap ON rc.capability = cap.name
                   WHERE rc.capability = :cap AND ctx.id IN ($ctxids)
                ORDER BY rc.roleid ASC, ctx.depth DESC";
       
      The role_capabilities table should be joined with the role table because when a role is removed, the roleid data related column in the role_capabilities table remains. As a quick solution to address the missing cascade deletion, I suggest adding JOIN {role} r ON r.id = rc.roleid to the query.
       
      I came across with the issue described above by clicling in settings tab in module forum after remove some user roles:

       
      Exception - role_get_name(): Argument #1 ($role) must be of type stdClass, null given, called in [dirroot]/lib/accesslib.php on line 4634

            Unassigned Unassigned
            Pedro Garcia Pedro Luis Garcia Leiva
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.