Moodle
  1. Moodle
  2. MDL-37559

Other Users page does not list all roles

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.4, 2.4.1, 2.5
    • Fix Version/s: 2.3.5, 2.4.2
    • Component/s: Roles / Access
    • Labels:
      None
    • Testing Instructions:
      Hide

      1/ clone manager role
      2/ assign manager and the cloned role to one user in the "Other users page" in some course
      3/ verify that after reload the page shows both roles

      Show
      1/ clone manager role 2/ assign manager and the cloned role to one user in the "Other users page" in some course 3/ verify that after reload the page shows both roles
    • Workaround:
      Hide

      One way to resolve this issue is to wrap this line with a statement to ensure that the array has not been set before trying to instantiate a new array.

      ie.
      if (! isset($users[$userrole->id]['roles']))

      { $users[$userrole->id]['roles'] = array(); }

      This will keep any previous roles array data, and allow multiple roles to be displayed.

      Show
      One way to resolve this issue is to wrap this line with a statement to ensure that the array has not been set before trying to instantiate a new array. ie. if (! isset($users [$userrole->id] ['roles'] )) { $users[$userrole->id]['roles'] = array(); } This will keep any previous roles array data, and allow multiple roles to be displayed.
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull 2.4 Branch:
      w03_MDL-37559_m24_otherusers
    • Pull Master Branch:
      w03_MDL-37559_m25_otherusers
    • Rank:
      47211

      Description

      When viewing the Other users page for a Course, and a User has multiple roles, only 1 of the roles are displayed.

      In issue is caused by line number 843 in moodle/enrol/locallib.php for Moodle Stable version 2.4.1 (possibly other versions). If multiple roles are evident for the same user, this line '$users[$userrole->id]['roles'] = array();' will recreate the roles array for each role iteration. If the roles array was created and populated for a previous iteration, the data is lost. It serves as a 'last in wins' situation.

        Issue Links

          Activity

          Hide
          Petr Škoda added a comment -

          Thanks for the report.

          Show
          Petr Škoda added a comment - Thanks for the report.
          Hide
          Aparup Banerjee added a comment -

          thanks, thats been integrated now into 23, 24 and master for testing.

          Show
          Aparup Banerjee added a comment - thanks, thats been integrated now into 23, 24 and master for testing.
          Hide
          Andrew Davis added a comment - - edited

          This is working perfectly in master but there is a problem in both 2.4 and 2.3. On the "other users" page after you assign the user the two roles the user does not appear when the page reloads. They do however now appear on the enrolled user's page and both of their roles are shown.

          Petr, are you able to reproduce what I'm seeing in 2.4 or 2.3? Is it due to this issue or is it unrelated?

          I've also raised MDL-37638 which is extremely minor.

          Show
          Andrew Davis added a comment - - edited This is working perfectly in master but there is a problem in both 2.4 and 2.3. On the "other users" page after you assign the user the two roles the user does not appear when the page reloads. They do however now appear on the enrolled user's page and both of their roles are shown. Petr, are you able to reproduce what I'm seeing in 2.4 or 2.3? Is it due to this issue or is it unrelated? I've also raised MDL-37638 which is extremely minor.
          Hide
          Petr Škoda added a comment -

          Hi, if user is already enrolled they do not appear on the "Other users" page.

          Show
          Petr Škoda added a comment - Hi, if user is already enrolled they do not appear on the "Other users" page.
          Hide
          Andrew Davis added a comment -

          Hrmmm, maybe it is working. I've had a second look. Passing.

          Show
          Andrew Davis added a comment - Hrmmm, maybe it is working. I've had a second look. Passing.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Surely you will be happy to know that your code is now part of Moodle upstream. Thanks, thanks!

          Closing as fixed, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Surely you will be happy to know that your code is now part of Moodle upstream. Thanks, thanks! Closing as fixed, ciao
          Hide
          Huy Hoang added a comment -

          Sorry for poking a closed ticket, but this bug is also in Moodle 2.2.7+ (Build: 20130208).

          Show
          Huy Hoang added a comment - Sorry for poking a closed ticket, but this bug is also in Moodle 2.2.7+ (Build: 20130208).
          Hide
          Petr Škoda added a comment -

          Yes, 2.2.x is not receiving more bug fixes, please upgrade.

          Show
          Petr Škoda added a comment - Yes, 2.2.x is not receiving more bug fixes, please upgrade.

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: