Set outage metadata headers before echoing injected warning-bar code to avoid headers-already-sent

This commit is contained in:
Waleed Hassan
2026-07-13 09:50:31 +01:00
parent 4976c5c3b6
commit f785693d06
+5 -4
View File
@@ -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(),