Merge branch 'wip-MDL-53274-master' of https://github.com/marinaglancy/moodle

This commit is contained in:
Dan Poltawski
2016-03-29 17:12:42 +08:00
+5
View File
@@ -443,10 +443,15 @@ class moodle_page {
* @return context the main context to which this page belongs.
*/
protected function magic_get_context() {
global $CFG;
if (is_null($this->_context)) {
if (CLI_SCRIPT or NO_MOODLE_COOKIES) {
// Cli scripts work in system context, do not annoy devs with debug info.
// Very few scripts do not use cookies, we can safely use system as default context there.
} else if (AJAX_SCRIPT && $CFG->debugdeveloper) {
// Throw exception inside AJAX script in developer mode, otherwise the debugging message may be missed.
throw new coding_exception('$PAGE->context was not set. You may have forgotten '
.'to call require_login() or $PAGE->set_context()');
} else {
debugging('Coding problem: $PAGE->context was not set. You may have forgotten '
.'to call require_login() or $PAGE->set_context(). The page may not display '