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

Details

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

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              skodak Petr Skoda
              dougiamas Martin Dougiamas
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Sara Arjona (@sarjona)
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                24/Nov/10