From d42b25cbf6d3f1e51cb2a3149f1ff54cc5474bc9 Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 7 Apr 2016 16:09:16 +0200 Subject: * Prado upgrade (to 3.3.r6b8e6601752b21a8a96c385a5529bbec7bb2b408) --- lib/prado/framework/PradoBase.php | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'lib/prado/framework/PradoBase.php') diff --git a/lib/prado/framework/PradoBase.php b/lib/prado/framework/PradoBase.php index de8c465..7cd2618 100644 --- a/lib/prado/framework/PradoBase.php +++ b/lib/prado/framework/PradoBase.php @@ -7,7 +7,7 @@ * * @author Qiang Xue * @link https://github.com/pradosoft/prado - * @copyright Copyright © 2005-2015 The PRADO Group + * @copyright Copyright © 2005-2016 The PRADO Group * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT * @package System */ @@ -83,10 +83,18 @@ class PradoBase * Sets error handler to be Prado::phpErrorHandler */ set_error_handler(array('PradoBase','phpErrorHandler')); + /** + * Sets shutdown function to be Prado::phpFatalErrorHandler + */ + register_shutdown_function(array('PradoBase','phpFatalErrorHandler')); /** * Sets exception handler to be Prado::exceptionHandler */ set_exception_handler(array('PradoBase','exceptionHandler')); + /** + * Disable php's builtin error reporting to avoid duplicated reports + */ + ini_set('display_errors', 0); } /** @@ -97,8 +105,6 @@ class PradoBase public static function autoload($className) { include_once($className.self::CLASS_FILE_EXT); - if(!class_exists($className,false) && !interface_exists($className,false)) - self::fatalError("Class file for '$className' cannot be found."); } /** @@ -134,6 +140,23 @@ class PradoBase throw new TPhpErrorException($errno,$errstr,$errfile,$errline); } + /** + * PHP shutdown function used to catch fatal errors. + * This method should be registered as PHP error handler using + * {@link register_shutdown_function}. The method throws an exception that + * contains the error information. + */ + public static function phpFatalErrorHandler() + { + $error = error_get_last(); + if($error && + TPhpErrorException::isFatalError($error) && + error_reporting() & $error['type']) + { + self::exceptionHandler(new TPhpErrorException($error['type'],$error['message'],$error['file'],$error['line'])); + } + } + /** * Default exception handler. * This method should be registered as default exception handler using -- cgit v1.2.3