Skip to content

Commit

Permalink
BUGFIX: Streamline exit(1) to web response with HTTP status code 500
Browse files Browse the repository at this point in the history
With this critical error messages like the following now sends the HTTP status code 500 instead 200 in order to state something is not okay on the server side.

Flow could not create the directory "/var/www/html/Data/Persistent". Please check the file permissions manually or run "sudo ./flow flow:core:setfilepermissions" to fix the problem. (Error #1347526553)

Resolves: neos#3364
  • Loading branch information
Christoph Lehmann authored and vcg-development committed Oct 22, 2024
1 parent e86a376 commit 079198c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Neos.Flow/Classes/Core/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ protected function defineConstants()
$expectedPath = Files::getUnixStylePath(realpath(FLOW_PATH_FLOW)) . '/';
if ($testPath !== $expectedPath) {
echo('Flow: Invalid root path. (Error #1248964375)' . PHP_EOL . '"' . $testPath . '" does not lead to' . PHP_EOL . '"' . $expectedPath . '"' . PHP_EOL);
http_response_code(500);
exit(1);
}
define('FLOW_PATH_ROOT', $rootPath);
Expand Down Expand Up @@ -561,16 +562,19 @@ protected function ensureRequiredEnvironment()
}
if (DIRECTORY_SEPARATOR !== '/' && PHP_WINDOWS_VERSION_MAJOR < 6) {
echo('Flow does not support Windows versions older than Windows Vista or Windows Server 2008 (Error #1312463704)' . PHP_EOL);
http_response_code(500);
exit(1);
}

if (!extension_loaded('Reflection')) {
echo('The PHP extension "Reflection" is required by Flow.' . PHP_EOL);
http_response_code(500);
exit(1);
}
$method = new \ReflectionMethod(__CLASS__, __FUNCTION__);
if ($method->getDocComment() === false || $method->getDocComment() === '') {
echo('Reflection of doc comments is not supported by your PHP setup. Please check if you have installed an accelerator which removes doc comments.' . PHP_EOL);
http_response_code(500);
exit(1);
}

Expand All @@ -583,12 +587,14 @@ protected function ensureRequiredEnvironment()
if (!is_dir(FLOW_PATH_DATA) && !is_link(FLOW_PATH_DATA)) {
if (!@mkdir(FLOW_PATH_DATA)) {
echo('Flow could not create the directory "' . FLOW_PATH_DATA . '". Please check the file permissions manually or run "sudo ./flow flow:core:setfilepermissions" to fix the problem. (Error #1347526552)');
http_response_code(500);
exit(1);
}
}
if (!is_dir(FLOW_PATH_DATA . 'Persistent') && !is_link(FLOW_PATH_DATA . 'Persistent')) {
if (!@mkdir(FLOW_PATH_DATA . 'Persistent')) {
echo('Flow could not create the directory "' . FLOW_PATH_DATA . 'Persistent". Please check the file permissions manually or run "sudo ./flow flow:core:setfilepermissions" to fix the problem. (Error #1347526553)');
http_response_code(500);
exit(1);
}
}
Expand All @@ -597,6 +603,7 @@ protected function ensureRequiredEnvironment()
$oldMask = umask(000);
if (!@mkdir(FLOW_PATH_TEMPORARY, 0777, true)) {
echo('Flow could not create the directory "' . FLOW_PATH_TEMPORARY . '". Please check the file permissions manually or run "sudo ./flow flow:core:setfilepermissions" to fix the problem. (Error #1441354578)');
http_response_code(500);
exit(1);
}
umask($oldMask);
Expand Down

0 comments on commit 079198c

Please sign in to comment.