1a3a89b90f
Passing the same object means enrol_cohort does not recognise a change in role when an edit or batch course upload operation is done. * enrol/editinstance.php was modifying $instance before passing it to enrol_plugin::update_instance() so the latter never sees a difference versus $data. This is redundant since update_instance() is doing the same thing a second time. * admin/tool/uploadcourse/classes/course.php is passing the same object as both arguments to enrol_plugin::update_instance(). There is an expectation that update_enrol_plugin_data() is to mutate its $instance argument and then return it based on how derived classes in enrol_guest and enrol_self behave, so cloning $instance within update_enrol_plugin_data() before mutating it isn't an option.