mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-58936 core: ensure 'page->context' is not null
When using $page->context it calls magic_get_context() in lib/pagelib.php. This method sets the context to context_system::instance() if it is currently null and returns that as the context. However, when installing a new site context_system::instance() also returns null.
This commit is contained in:
parent
17fb1d84a2
commit
004dcb4f58
@ -315,6 +315,12 @@ class page_requirements_manager {
|
||||
|
||||
$iconsystem = \core\output\icon_system::instance();
|
||||
|
||||
// It is possible that the $page->context is null, so we can't use $page->context->id.
|
||||
$contextid = null;
|
||||
if (!is_null($page->context)) {
|
||||
$contextid = $page->context->id;
|
||||
}
|
||||
|
||||
$this->M_cfg = array(
|
||||
'wwwroot' => $CFG->httpswwwroot, // Yes, really. See above.
|
||||
'sesskey' => sesskey(),
|
||||
@ -326,7 +332,7 @@ class page_requirements_manager {
|
||||
'admin' => $CFG->admin,
|
||||
'svgicons' => $page->theme->use_svg_icons(),
|
||||
'usertimezone' => usertimezone(),
|
||||
'contextid' => $page->context->id,
|
||||
'contextid' => $contextid,
|
||||
);
|
||||
if ($CFG->debugdeveloper) {
|
||||
$this->M_cfg['developerdebug'] = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user