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

Removing "Custom instance name" from Cohort enrollment when Cohorts no longer exist causes Coding error

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.4.7, 2.5.3
    • 2.4.3, 2.5
    • Cohorts
    • MOODLE_24_STABLE, MOODLE_25_STABLE
    • MOODLE_24_STABLE, MOODLE_25_STABLE
    • w41_MDL-42047_m26_cohortdel
    • Hide

      1/ enable cohort sync enrol plugin and set it to disable enrolments instead of full unenrol
      2/ create cohort
      3/ use the cohort in course cohort sync
      4/ delete the cohort
      5/ make sure the enrolment methods page shows the disabled method

      Show
      1/ enable cohort sync enrol plugin and set it to disable enrolments instead of full unenrol 2/ create cohort 3/ use the cohort in course cohort sync 4/ delete the cohort 5/ make sure the enrolment methods page shows the disabled method
    • 1
    • BACKEND Sprint 5

      When editing cohort sync enrollment in a course if the user removes the "custom instance name" for the instance and the cohorts that the instance points to no longer exist, this causes the following error on that course's enrollment methods screen:

      Notice: Trying to get property of non-object in /opt/rlcache/www/master/enrol/cohort/lib.php on line 49

      Notice: Trying to get property of non-object in /opt/rlcache/www/master/enrol/cohort/lib.php on line 49

      Coding error detected, it must be fixed by a programmer: Invalid context id specified context::instance_by_id()

      More information about this error
      Debug info:
      Error code: codingerror
      Stack trace:

      line 5221 of /lib/accesslib.php: coding_exception thrown
      line 49 of /enrol/cohort/lib.php: call to context::instance_by_id()
      line 165 of /enrol/instances.php: call to enrol_cohort_plugin->get_instance_name()

      This stops the user from being able to view/edit enrollment methods for a course and you have to re-add a name via database in order to get back to the enrollment methods screen for that course.

      To Replicate:

      Create a Cohort with members at system level
      Add a cohort sync enrollment method to a course and give it a Custom Instance Name and choose the cohort you just created.
      Now go back to Site Admin -> Users -> Cohorts and delete the cohort you created.
      Go to the course where you added the cohort sync and edit the enrollment method and remove the Custom Instance Name and save.

      I know this seems like a unique situation but I actually had this happen and had to really search for the answer as the error code does not really lead you to the "name" of the instance, as at first glance it leads you to believe it is a context issue.

            skodak Petr Skoda
            heather.williams Heather Williams
            Damyon Wiese Damyon Wiese
            Mark Nelson Mark Nelson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.