From 56953adc5b9e3efe09a44c36446414102880802f Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Thu, 26 Aug 2010 14:57:32 +0000 Subject: [PATCH] MDL-23824 prevent header warnings on CLI after fatal config.php error detected --- lib/setup.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index 8db3cf84c99..55e27c1951b 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -48,21 +48,26 @@ $CFG->dirroot = dirname(dirname(__FILE__)); // Normalise dataroot - we do not want any symbolic links, trailing / or any other weirdness there if (!isset($CFG->dataroot)) { - header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable'); + if (isset($_SERVER['REMOTE_ADDR'])) { + header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable'); + } echo('Fatal error: $CFG->dataroot is not specified in config.php! Exiting.'); exit(1); } $CFG->dataroot = realpath($CFG->dataroot); if ($CFG->dataroot === false) { - header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable'); + if (isset($_SERVER['REMOTE_ADDR'])) { + header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable'); + } echo('Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.'); exit(1); } // wwwroot is mandatory if (!isset($CFG->wwwroot) or $CFG->wwwroot === 'http://example.com/moodle') { - // trigger_error() is not correct here, no need to log this - header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable'); + if (isset($_SERVER['REMOTE_ADDR'])) { + header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable'); + } echo('Fatal error: $CFG->wwwroot is not configured! Exiting.'); exit(1); } -- 2.43.0