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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: 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

      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.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              skodak Petr Skoda 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
              skodak Petr Skoda 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.alcantara Luis Gustavo Mueller de Alcantara added a comment -

              My pleasure to help.

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

              Thanks guys - this has been integrated now!

              Show
              samhemelryk Sam Hemelryk added a comment - Thanks guys - this has been integrated now!
              Hide
              samhemelryk 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
              samhemelryk 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
              stronk7 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
              stronk7 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.alcantara 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.alcantara 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:
                    Fix Release Date:
                    9/Jan/12