Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In case of fatal php errors and other unhandled exceptions no html er… #24075

Merged
merged 1 commit into from
Apr 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions console.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
return;
}

function exceptionHandler($exception) {
echo "An unhandled exception has been thrown:" . PHP_EOL;
echo $exception;
exit(1);
}
try {
require_once 'lib/base.php';

Expand All @@ -53,6 +58,8 @@
exit(0);
}

set_exception_handler('exceptionHandler');

if (!OC_Util::runningOnWindows()) {
if (!function_exists('posix_getuid')) {
echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL;
Expand Down Expand Up @@ -87,7 +94,5 @@
$application->loadCommands(new ArgvInput(), new ConsoleOutput());
$application->run();
} catch (Exception $ex) {
echo "An unhandled exception has been thrown:" . PHP_EOL;
echo $ex;
exit(1);
exceptionHandler($ex);
}
11 changes: 3 additions & 8 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,14 +545,9 @@ public static function init() {
OC_Util::isSetLocaleWorking();

if (!defined('PHPUNIT_RUN')) {
$logger = \OC::$server->getLogger();
OC\Log\ErrorHandler::setLogger($logger);
if (\OC::$server->getConfig()->getSystemValue('debug', false)) {
OC\Log\ErrorHandler::register(true);
set_exception_handler(array('OC_Template', 'printExceptionErrorPage'));
} else {
OC\Log\ErrorHandler::register();
}
OC\Log\ErrorHandler::setLogger(\OC::$server->getLogger());
$debug = \OC::$server->getConfig()->getSystemValue('debug', false);
OC\Log\ErrorHandler::register($debug);
}

// register the stream wrappers
Expand Down
3 changes: 3 additions & 0 deletions lib/private/log/errorhandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public static function register($debug=false) {

if ($debug) {
set_error_handler(array($handler, 'onAll'), E_ALL);
if (\OC::$CLI) {
set_exception_handler(array('OC_Template', 'printExceptionErrorPage'));
}
} else {
set_error_handler(array($handler, 'onError'));
}
Expand Down