Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Avoid recursive exceptions

givanzc12c592e84eb
diff --git a/system/core/startup.php b/system/core/startup.php
index f280406..4b03fc8 100755
--- a/system/core/startup.php
+++ b/system/core/startup.php
@@ -262,16 +262,30 @@ function exceptionToArray($exception, $file = false) {
}
function exceptionHandler($exception) {
- $message = exceptionToArray($exception, $exception->getFile());
+ static $handled;
+
+ if ($handled) {
+ if (DEBUG) {
+ echo $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine();
+ } else {
+ die('Server error, enable debug for more info');
+ }
+ return;
+ }
+ $handled = true;
+ $message = exceptionToArray($exception, $exception->getFile());
+ $handled = true;
//check if error is generated by a plugin and disable it
pluginErrorCheck($message['file']);
- return FrontController::notFound(false, $message, 500);
+ FrontController::notFound(false, $message, 500);
//pluginErrorCheck($file);
- echo '<b>Exception:</b><pre>';
- print_r($message);
- echo '</pre>';
+ if (DEBUG) {
+ echo '<b>Exception:</b><pre>';
+ print_r($message);
+ echo '</pre>';
+ }
}
function vErrorHandler($errno, $errstr, $errfile, $errline) {
@@ -325,6 +339,8 @@ function pluginErrorCheck($file) {
logError(sprintf(\Vvveb\__('Disabling "%s" plugin.'), $plugin));
Plugins::deactivate($plugin);
}
+
+ return true;
}
}
diff --git a/system/core/view.php b/system/core/view.php
index 93de254..5b1d00a 100644
--- a/system/core/view.php
+++ b/system/core/view.php
@@ -480,8 +480,19 @@ class View {
return $return;
}
} catch (\ParseError | \Error $e) {
- $data = \Vvveb\System\Core\exceptionToArray($e, $this->compiledTemplate);
+ static $handled;
+
+ if ($handled) {
+ if (DEBUG) {
+ echo $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine();
+ } else {
+ die('Server error, enable debug for more info');
+ }
+ return;
+ }
+ $handled = true;
+ $data = \Vvveb\System\Core\exceptionToArray($e, $this->compiledTemplate);
return FrontController :: notFound(false, $data, 500);
}
}