diff options
Diffstat (limited to 'core/FrontController.php')
-rw-r--r-- | core/FrontController.php | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/core/FrontController.php b/core/FrontController.php index 22fa669861..d02f00b96e 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -53,7 +53,7 @@ use Piwik\Session; * * @package Piwik * @subpackage FrontController - * @static method \Piwik\FrontController getInstance() + * @method static \Piwik\FrontController getInstance() */ class FrontController extends Singleton { @@ -244,6 +244,23 @@ class FrontController extends Singleton || SettingsServer::isArchivePhpTriggered(); } + static public function setUpSafeMode() + { + register_shutdown_function(array('\\Piwik\\FrontController','triggerSafeModeWhenError')); + } + + static public function triggerSafeModeWhenError() + { + $lastError = error_get_last(); + if (!empty($lastError) && $lastError['type'] == E_ERROR) { + $controller = FrontController::getInstance(); + $controller->init(); + $message = $controller->dispatch('CorePluginsAdmin', 'safemode', array($lastError)); + + echo $message; + } + } + /** * Loads the config file and assign to the global registry * This is overridden in tests to ensure test config file is used |