In case of fatal php errors and other unhandled exceptions no html error page is expected to be displayed in the console

This commit is contained in:
Thomas Müller 2016-04-18 22:30:01 +02:00
parent 51975d360a
commit c609abf075
No known key found for this signature in database
GPG key ID: A943788A3BBEC44C
3 changed files with 14 additions and 11 deletions

View file

@ -42,6 +42,11 @@ if (version_compare(PHP_VERSION, '5.4.0') === -1) {
return; return;
} }
function exceptionHandler($exception) {
echo "An unhandled exception has been thrown:" . PHP_EOL;
echo $exception;
exit(1);
}
try { try {
require_once 'lib/base.php'; require_once 'lib/base.php';
@ -53,6 +58,8 @@ try {
exit(0); exit(0);
} }
set_exception_handler('exceptionHandler');
if (!OC_Util::runningOnWindows()) { if (!OC_Util::runningOnWindows()) {
if (!function_exists('posix_getuid')) { if (!function_exists('posix_getuid')) {
echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL; echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL;
@ -87,7 +94,5 @@ try {
$application->loadCommands(new ArgvInput(), new ConsoleOutput()); $application->loadCommands(new ArgvInput(), new ConsoleOutput());
$application->run(); $application->run();
} catch (Exception $ex) { } catch (Exception $ex) {
echo "An unhandled exception has been thrown:" . PHP_EOL; exceptionHandler($ex);
echo $ex;
exit(1);
} }

View file

@ -545,14 +545,9 @@ class OC {
OC_Util::isSetLocaleWorking(); OC_Util::isSetLocaleWorking();
if (!defined('PHPUNIT_RUN')) { if (!defined('PHPUNIT_RUN')) {
$logger = \OC::$server->getLogger(); OC\Log\ErrorHandler::setLogger(\OC::$server->getLogger());
OC\Log\ErrorHandler::setLogger($logger); $debug = \OC::$server->getConfig()->getSystemValue('debug', false);
if (\OC::$server->getConfig()->getSystemValue('debug', false)) { OC\Log\ErrorHandler::register($debug);
OC\Log\ErrorHandler::register(true);
set_exception_handler(array('OC_Template', 'printExceptionErrorPage'));
} else {
OC\Log\ErrorHandler::register();
}
} }
// register the stream wrappers // register the stream wrappers

View file

@ -44,6 +44,9 @@ class ErrorHandler {
if ($debug) { if ($debug) {
set_error_handler(array($handler, 'onAll'), E_ALL); set_error_handler(array($handler, 'onAll'), E_ALL);
if (\OC::$CLI) {
set_exception_handler(array('OC_Template', 'printExceptionErrorPage'));
}
} else { } else {
set_error_handler(array($handler, 'onError')); set_error_handler(array($handler, 'onError'));
} }