diff options
-rw-r--r-- | it_auto_prepend.php | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/it_auto_prepend.php b/it_auto_prepend.php index ee804b2..c71e38c 100644 --- a/it_auto_prepend.php +++ b/it_auto_prepend.php @@ -30,6 +30,8 @@ function it_initialize() if (!$it_initrecursion++) { + $error_reporting = error_reporting(); + error_reporting($error_reporting & ~E_NOTICE); # ITools is not (unpatched) E_NOTICE safe $it_path = dirname(__FILE__); if ($webmode = $_SERVER['REMOTE_ADDR']) # Web? @@ -43,6 +45,9 @@ function it_initialize() $include_path = ini_get('include_path'); + @set_error_handler("it_errorhandler", E_USER_ERROR | E_RECOVERABLE_ERROR | E_WARNING | E_USER_WARNING | E_NOTICE | E_USER_NOTICE); + error_reporting($error_reporting); # Restore user setting once we installed error handler + if ($autoloader = function_exists('spl_autoload_register') && spl_autoload_register('it_classloader')) { ini_set('include_path', $it_path . PATH_SEPARATOR . $include_path); @@ -70,7 +75,6 @@ function it_initialize() die(($webmode ? "<pre>" : "") . "Seems to be running in shared environment, manually set\n\$GLOBALS['IT_SYNTAXCONVERTER_DIR'] in $it_path/auto_prepend_local.php\nto either:\n a) FALSE (syntax conversion disabled) or\n b) the path to a writeable directory (NOTE: THIS IS UNSAFE!) or\n c) install the PHP patch from http://cschneid.com/php/\n" . ($webmode ? "</pre>" : "")); } - @set_error_handler("it_errorhandler", E_USER_ERROR | E_RECOVERABLE_ERROR | E_WARNING | E_USER_WARNING | E_NOTICE | E_USER_NOTICE); ini_set('include_path', $GLOBALS['IT_SYNTAXCONVERTER_DIR'] . "/it_syntaxconverter" . PATH_SEPARATOR . $it_path . PATH_SEPARATOR . $include_path); $user_includes = explode(PATH_SEPARATOR, $include_path); @@ -166,7 +170,9 @@ function it_classloader($classname) function it_errorhandler($errno, $errstr, $errfile, $errline, $errcontext) { - if ($result = error_reporting() & $errno) # Is this error enabled? + $error_reporting = error_reporting(0); # Disable error reporting while handling error + + if ($result = $error_reporting & $errno) # Is this error enabled? { static $it_errnames = array(); @@ -193,11 +199,21 @@ function it_errorhandler($errno, $errstr, $errfile, $errline, $errcontext) it::fatal($error); break; + case E_NOTICE: + if ((dirname($errfile) == dirname(__FILE__)) && preg_match('/undefined|non-object/i', $errstr)) + { + $result = true; # Silence E_NOTICE about undefined stuff in ITools files + break; + } + # FALLTHROUGH + default: it::error($error); break; } } + error_reporting($error_reporting); + return $result; # True means do not execute standard PHP error handler } |