From f1c6d647bcb51236536beb145da1c8f1e6cb113e Mon Sep 17 00:00:00 2001 From: Brendan Heywood Date: Wed, 14 Sep 2016 18:15:21 +1000 Subject: [PATCH] MDL-55916 setup: Maintenance mode serves HTTP 503 --- lib/setup.php | 3 +++ lib/weblib.php | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/lib/setup.php b/lib/setup.php index 4026d1ba6b8..bc0b759042e 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -313,6 +313,9 @@ if (!defined('WS_SERVER')) { // Detect CLI maintenance mode - this is useful when you need to mess with database, such as during upgrades if (file_exists("$CFG->dataroot/climaintenance.html")) { if (!CLI_SCRIPT) { + header($_SERVER['SERVER_PROTOCOL'] . ' 503 Moodle under maintenance'); + header('Status: 503 Moodle under maintenance'); + header('Retry-After: 300'); header('Content-type: text/html; charset=utf-8'); header('X-UA-Compatible: IE=edge'); /// Headers to make it not cacheable and json diff --git a/lib/weblib.php b/lib/weblib.php index 388218531a9..f0a63d57b10 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2934,6 +2934,10 @@ function rebuildnolinktag($text) { function print_maintenance_message() { global $CFG, $SITE, $PAGE, $OUTPUT; + header($_SERVER['SERVER_PROTOCOL'] . ' 503 Moodle under maintenance'); + header('Status: 503 Moodle under maintenance'); + header('Retry-After: 300'); + $PAGE->set_pagetype('maintenance-message'); $PAGE->set_pagelayout('maintenance'); $PAGE->set_title(strip_tags($SITE->fullname));