diff --git a/classes/local/controllers/infopage.php b/classes/local/controllers/infopage.php index 0e7cded..3f64ff4 100644 --- a/classes/local/controllers/infopage.php +++ b/classes/local/controllers/infopage.php @@ -107,10 +107,8 @@ class infopage { $PAGE->set_heading($this->outage->get_title()); $PAGE->set_url(new moodle_url('/auth/outage/info.php')); - // No hooks injecting into this page, do it manually. - echo outagelib::get_inject_code(); - - // Inject metadata into the header before output. + // Inject metadata into the header before any output starts, otherwise header() will + // fail once outagelib::get_inject_code() below has echoed anything. if (!empty($this->outage->metadata)) { $safemeta = str_replace(["\r", "\n"], '', $this->outage->metadata); header('X-Outage-Metadata: ' . $safemeta); @@ -118,6 +116,9 @@ class infopage { header('X-Outage-EndTime: ' . $this->outage->stoptime); } + // No hooks injecting into this page, do it manually. + echo outagelib::get_inject_code(); + echo $OUTPUT->header(); $viewbag = [ 'admin' => is_siteadmin(),