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

enrol/database setup_enrolments assignment should be comparison

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.7, 1.7.1, 1.7.2, 1.8, 1.9, 2.0
    • None
    • Enrolments
    • None
    • Any
    • MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE

    Description

      In enrol/database/enrol.php's setup_enrolments(), the comparison to search for an already existing user role uses an assignment when a comparison is intended. The result is that any existing role of the user is matched against the currently checked role. This causes significant failure of enrolment synchronization.

      This occurs in 1.32 on lines 111-112.

      107 // Search the role assignments to see if this user
      108 // already has this role in this context. If it is, we
      109 // skip to the next course.
      110 foreach($existing as $key => $role_assignment) {
      111 if ($role_assignment->roleid = $role->id
      112 && $role_assignment->contextid = $context->id)

      { 113 unset($existing[$key]); 114 //error_log('[ENROL_DB] User is already enroled in course '.$course->idnumber); 115 continue 2; 116 }

      which should be:
      111 if ($role_assignment->roleid == $role->id
      112 && $role_assignment->contextid == $context->id) {

      Attachments

        Issue Links

          Activity

            People

              martinlanghoff Martín Langhoff
              bluenovember Clinton Graham
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: