-
Bug
-
Resolution: Fixed
-
Minor
-
2.4.3, 2.5
-
MOODLE_24_STABLE, MOODLE_25_STABLE
-
MOODLE_24_STABLE, MOODLE_25_STABLE
-
w41_
MDL-42047_m26_cohortdel -
-
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.