in debug mode, when we duplicate activity, and delete it, we've a popup error:
$PAGE->context was not set. You may have forgotten to call require_login() or $PAGE->set_context()
Error code: codingerror
|
* line 488 of /lib/pagelib.php: coding_exception thrown |
* line 820 of /lib/pagelib.php: call to moodle_page->magic_get_context() |
* line 1456 of /lib/weblib.php: call to moodle_page->__get() |
* line 474 of /mod/url/locallib.php: call to format_string() |
* line 109 of /mod/url/locallib.php: call to url_get_variable_values() |
* line 247 of /mod/url/lib.php: call to url_get_full_url() |
* line 465 of /course/lib.php: call to url_get_coursemodule_info() |
* line 671 of /lib/modinfolib.php: call to get_array_of_activities() |
* line 463 of /lib/modinfolib.php: call to course_modinfo::inner_build_course_cache() |
* line 418 of /lib/modinfolib.php: call to course_modinfo->__construct() |
* line 2169 of /lib/modinfolib.php: call to course_modinfo::instance() |
* line 2243 of /lib/modinfolib.php: call to get_fast_modinfo() |
* line 3591 of /course/externallib.php: call to get_course_and_cm_from_cmid() |
* line 244 of /lib/externallib.php: call to core_course_external::edit_module() |
* line 59 of /lib/ajax/service.php: call to external_api::call_external_function() |
We can't reproduce this with a new empty course.
But this is corrected with this changes in /mod/url/locallib.php, function url_get_variable_values() :
Whenever there is a call to format_string(...), inject context «, true, array('context' => $coursecontext)» like this :
$values = array (
|
'courseid' => $course->id, |
'coursefullname' => format_string($course->fullname, true, array('context' => $coursecontext)), |
'courseshortname' => format_string($course->shortname, true, array('context' => $coursecontext)), |
'courseidnumber' => $course->idnumber, |
'coursesummary' => $course->summary, |
'courseformat' => $course->format, |
'lang' => current_language(), |
'sitename' => format_string($site->fullname, true, array('context' => $coursecontext)), |
'serverurl' => $CFG->wwwroot, |
'currenttime' => time(), |
'urlinstance' => $url->id, |
'urlcmid' => $cm->id, |
'urlname' => format_string($url->name, true, array('context' => $coursecontext)), |
'urlidnumber' => $cm->idnumber, |
|
I don't know if it's the good way, but this work for us.
Why initially 'courseshortname' have context injection, but not the others ?
- duplicates
-
MDL-66936 URL resource causes exception in course modinfo cache rebuild
-
- Closed
-