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

get_users_by_capability has problem with activity module contexts when that capability is defined in any default user role

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 2.0
    • 1.9
    • Roles / Access
    • None
    • MOODLE_19_STABLE
    • MOODLE_20_STABLE

      The problem is that if these conditions coincide:

      1) Default role (eg authenticaled users) has ALLOW permission for a module thing like mod/choice:choose
      2) We are checking for that capability in an activity module context in a course (eg a choice activity in a course)

      Then we are led inexorably to:

      if ($defaultroleinteresting) {
      $sql = "SELECT $fields
      FROM {$CFG->prefix}user u
      $uljoin
      $where
      ORDER BY $sort";
      return get_records_sql($sql, $limitfrom, $limitnum);
      }

      which can easily return all the site users in one list.

      Not only is not accurate (in terms of what the module programmer expected) it can easily surpass the process memory limit for a large site and thus break.

      We need to somehow treat this rather common case differently, and just return those people who not only have the capabilty for that activity but also moodle/course:view for the relevant course context.

            skodak Petr Skoda
            dougiamas Martin Dougiamas
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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