Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'wip-MDL-53274-master' of https://github.com/marinaglanc…
  • Loading branch information
danpoltawski committed Mar 29, 2016
2 parents b928092 + 67fc782 commit 0729ea9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/pagelib.php
Expand Up @@ -443,10 +443,15 @@ protected function magic_get_categories() {
* @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 '
Expand Down

0 comments on commit 0729ea9

Please sign in to comment.