MDL-71012 setup: Return 500 error code for setup errors.

This commit is contained in:
Jess Ansell
2021-03-22 14:05:45 +00:00
parent fc335f5ea0
commit 52bc582e77
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -147,7 +147,7 @@ if (defined('BEHAT_SITE_RUNNING')) {
// Normalise dataroot - we do not want any symbolic links, trailing / or any other weirdness there
if (!isset($CFG->dataroot)) {
if (isset($_SERVER['REMOTE_ADDR'])) {
header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error ');
}
echo('Fatal error: $CFG->dataroot is not specified in config.php! Exiting.'."\n");
exit(1);
@@ -155,13 +155,13 @@ if (!isset($CFG->dataroot)) {
$CFG->dataroot = realpath($CFG->dataroot);
if ($CFG->dataroot === false) {
if (isset($_SERVER['REMOTE_ADDR'])) {
header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error ');
}
echo('Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.'."\n");
exit(1);
} else if (!is_writable($CFG->dataroot)) {
if (isset($_SERVER['REMOTE_ADDR'])) {
header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error ');
}
echo('Fatal error: $CFG->dataroot is not writable, admin has to fix directory permissions! Exiting.'."\n");
exit(1);
@@ -170,7 +170,7 @@ if ($CFG->dataroot === false) {
// wwwroot is mandatory
if (!isset($CFG->wwwroot) or $CFG->wwwroot === 'http://example.com/moodle') {
if (isset($_SERVER['REMOTE_ADDR'])) {
header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error ');
}
echo('Fatal error: $CFG->wwwroot is not configured! Exiting.'."\n");
exit(1);