Moodle
  1. Moodle
  2. MDL-30528

External database enrolment plugin is recreating role_assignments on every login attempt for each user.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.2, 2.2
    • Fix Version/s: 2.0.7, 2.1.4, 2.2.1
    • Component/s: Enrolments
    • Labels:
      None
    • Database:
      Any
    • Testing Instructions:
      Hide

      Enable external database authentication, also external database enrolment, create some data to the external database, and make some logins throught a user using this method. You should see the role_assignmets table recreating the instances on every login.

      The error I found is uppon line 186 @ /enrol/database/lib.php.
      Where it reads:
      "if (in_array($r->id, $roles)) {"
      it should be
      "if (in_array($r->roleid, $roles)) {"

      Show
      Enable external database authentication, also external database enrolment, create some data to the external database, and make some logins throught a user using this method. You should see the role_assignmets table recreating the instances on every login. The error I found is uppon line 186 @ /enrol/database/lib.php. Where it reads: "if (in_array($r->id, $roles)) {" it should be "if (in_array($r->roleid, $roles)) {"
    • Workaround:
      Hide

      Included in the attached patch file.

      Show
      Included in the attached patch file.
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      w50_MDL-30528_m23_enrolroleid
    • Rank:
      33239

      Description

      When we enable External Database Enrolment, every role_assignmet is reset for each user, each time he logs in. The result of this bug is an unnecessary increasing ID on table role_assignments.

      1. patch.patch
        0.6 kB
        Luis Gustavo Mueller de Alcantara

        Issue Links

          Activity

          Hide
          Petr Škoda added a comment - - edited

          Thanks a lot for the report and patch!

          TO integrators: please cherry pick to 2.2 and 2.1 branch.

          Show
          Petr Škoda added a comment - - edited Thanks a lot for the report and patch! TO integrators: please cherry pick to 2.2 and 2.1 branch.
          Hide
          Luis Gustavo Mueller de Alcantara added a comment -

          My pleasure to help.

          Show
          Luis Gustavo Mueller de Alcantara added a comment - My pleasure to help.
          Hide
          Sam Hemelryk added a comment -

          Thanks guys - this has been integrated now!

          Show
          Sam Hemelryk added a comment - Thanks guys - this has been integrated now!
          Hide
          Sam Hemelryk added a comment -

          Thanks guys, just been testing this now and can confirm I no longer get new role assignments after the first.

          Petr I was wondering - do we need to add upgrade code to clean up any multiple role assignments?

          Show
          Sam Hemelryk added a comment - Thanks guys, just been testing this now and can confirm I no longer get new role assignments after the first. Petr I was wondering - do we need to add upgrade code to clean up any multiple role assignments?
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Yes, you did it!

          Now your code is part of the best weeklies released ever, many thanks!

          Closing, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Yes, you did it! Now your code is part of the best weeklies released ever, many thanks! Closing, ciao
          Hide
          Luis Gustavo Mueller de Alcantara added a comment -

          Nice!

          Thank you guys for all the great job you have been doing to Moodle, and for the quick testing and updating.

          Show
          Luis Gustavo Mueller de Alcantara added a comment - Nice! Thank you guys for all the great job you have been doing to Moodle, and for the quick testing and updating.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: