From 8820f4e751eb24ee481d20efda35dfa30b08b3ae Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Mon, 18 Oct 2010 12:48:39 +0000 Subject: [PATCH] MDL-24723 new CLI maintenance mode --- lib/setup.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/setup.php b/lib/setup.php index 327f6b0276a..c9556167f5a 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -151,6 +151,26 @@ if (defined('WEB_CRON_EMULATED_CLI')) { } } +// 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('Content-type: text/html'); + /// Headers to make it not cacheable and json + @header('Cache-Control: no-store, no-cache, must-revalidate'); + @header('Cache-Control: post-check=0, pre-check=0', false); + @header('Pragma: no-cache'); + @header('Expires: Mon, 20 Aug 1969 09:23:00 GMT'); + @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + @header('Accept-Ranges: none'); + readfile("$CFG->dataroot/climaintenance.html"); + die; + } else { + define('CLI_MAINTENANCE', true); + } +} else { + define('CLI_MAINTENANCE', false); +} + // Detect ajax scripts - they are similar to CLI because we can not redirect, output html, etc. if (!defined('AJAX_SCRIPT')) { define('AJAX_SCRIPT', false);