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

lib/accesslib.php/count_role_users function give wrong results

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 1.7.4, 1.8.2
    • 1.8.5, 1.9
    • Roles / Access
    • None
    • any
    • MOODLE_17_STABLE, MOODLE_18_STABLE
    • MOODLE_18_STABLE, MOODLE_19_STABLE

    Description

      When assigning roles to a course the script /admin/roles/assign.php first give a quick summary of roles and the
      current number of users having these roles.

      Unfortunately the numbers are wrong , and do not match what is seen when getting role's details, since the called API function lib/accesslib.php/count_role_users do not filter out deleted users, i.e. users having the flag deleted set ...

      current SQL is :

      $SQL = "SELECT count
      FROM {$CFG->prefix}role_assignments r
      WHERE (r.contextid = $context->id $parentcontexts)
      AND r.roleid = $roleid";

      where it should be :

      $SQL = "SELECT count
      FROM {$CFG->prefix}role_assignments r,{$CFG->prefix}user u
      WHERE (r.contextid = $context->id $parentcontexts)
      AND r.roleid = $roleid
      AND r.userid=u.id
      AND not u.deleted";

      According to phpxref , this function is called only from admin/roles/assign.php, so this patch should be without other consequences.

      Cheers.

      Attachments

        Issue Links

          Activity

            People

              poltawski Dan Poltawski
              ppollet Patrick Pollet
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                3/Mar/08