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

get_role_users() with more than one role assigned to user

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      • All behat and unit tests should pass
      1. Turn debugging mode to full cream milk
      2. Go to Site administration ► Grades ► General settings
      3. Tick Non-editing teacher in gradebookroles so that both Non-editing teacher and Student are ticked
      4. Enrol a user as both a non-editing teacher and a student
      5. Test singleview report
        1. Try setting groups
        2. Try selecting grade items
        3. Try selecting users
        4. Try uptading grades
        5. You SHOULD NOT see any error
        6. You SHOULD NOT see duplicate users
      Show
      All behat and unit tests should pass Turn debugging mode to full cream milk Go to Site administration ► Grades ► General settings Tick Non-editing teacher in gradebookroles so that both Non-editing teacher and Student are ticked Enrol a user as both a non-editing teacher and a student Test singleview report Try setting groups Try selecting grade items Try selecting users Try uptading grades You SHOULD NOT see any error You SHOULD NOT see duplicate users
    • Affected Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-22309_master
    • Sprint:
      BACKEND Sprint 18

      Description

      When user has more than one role assigned, the query in get_role_users() gives more rows. Because $DB->get_records_sql() is used, it may lead to

      Did you remember to make the first column something unique in your call to get_records? Duplicate value xxx found in column 'id'.
      

      and only record per-user being returned. Using DISTINCT here would not work because every row has different role. Also, DISTINCT in combination with ORDER BY ir dangerous in PostgreSQL unless we make sure that ORDER BY fields are includes in SELECTed fields.

      Reproduce:
      =========
      1. Assign yourself both Teacher and Student in a course
      2. Visit the course settings page (with debugging on, of course)

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                4 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  12/Jan/15