Fix the error_reporting somewhat; until now, prevent E_STRICT errors were not correctly surpressed, but

we need to do this, because otherwise older plugins will prevent Serendipity from loading.

I actually wanted to at least "break" stuff and report errors, when $serendipity['production'] is set to "debug".

However, this does NOT work for me (PHP 5.2); even when set to "debug", E_STRICT errors do not seem to show up.
I'm quite at a loss here, so anyone reading this, go ahead and inspect.

At least it makes this version work when "older" plugins exists. It would be great if the code could be made to show the debug errors in debug mode.

I shuffled around the error_reporting() position because when someone sets the variable in serendipity_config_local.inc.php it would be too early to affect code flow; now it should evaluate the variable properly.
This commit is contained in:
Garvin Hicking 2013-01-20 01:24:23 +01:00
parent e952791bb1
commit 6f2858ad27
3 changed files with 23 additions and 16 deletions

View File

@ -82,6 +82,7 @@ if (!function_exists('errorToExceptionHandler')) {
global $serendipity;
$rep = ini_get('error_reporting');
// respect user has set php error_reporting to not display any errors at all
if (!($rep & $errStr)) { return false; }
// user used @ to specify ignoring all errors or $php_errormsg messages returned with error_reporting = 0
@ -90,6 +91,9 @@ if (!function_exists('errorToExceptionHandler')) {
if ($serendipity['production'] === true && ini_get('display_errors') == 0) { return false; }
// any other errors go here - throw errors as exception
if ($serendipity['production'] === 'debug') {
// We don't want the notices
echo '<p> == FULL DEBUG ERROR MODE == </p>';
echo '<pre>';
// trying to be as detailled as possible

View File

@ -309,7 +309,7 @@ class Serendipity_Smarty extends Smarty
}
// set smarty error reporting. General error_reporting is set in serendipity/serendipity_config.inc.php
$this->error_reporting = E_ALL & ~E_NOTICE ^ E_STRICT;
$this->error_reporting = E_ALL & ~(E_NOTICE|E_STRICT);
}

View File

@ -54,29 +54,16 @@ if (!isset($serendipity['production'])) {
// Set error reporting
// TODO: E_STRICT throws problematic errors due to "hook_event" being a static function, but all of our plugins don't really define that...
error_reporting(E_ALL & ~E_NOTICE ^ E_STRICT);
error_reporting(E_ALL & ~(E_STRICT|E_NOTICE));
if ($serendipity['production'] !== true) {
if ($serendipity['production'] === 'debug') {
error_reporting(E_ALL);
}
@ini_set('display_errors', 'on');
}
// The serendipity errorhandler string
$serendipity['errorhandler'] = 'errorToExceptionHandler';
//[internal callback function]: errorToExceptionHandler()
if(is_callable($serendipity['errorhandler'], false, $callable_name)) {
// set serendipity global error to exeption handler
#if ($serendipity['production'] === 'debug') {
# set_error_handler($serendipity['errorhandler'], E_ALL);
#} else {
// Caution! If we want to have the same noshow effect as upper set error_reporting(E_ALL) in 'debug' mode,
// do not clone it to set_error_handler(E_ALL), else everythimg is haltet to debug, which makes using debug obsolet.
set_error_handler($serendipity['errorhandler'], E_ALL & ~E_NOTICE ^ E_STRICT);
#}
}
// Default rewrite method
$serendipity['rewrite'] = 'none';
@ -266,6 +253,22 @@ if (!is_readable($local_config)) {
include($local_config);
if ($serendipity['production'] === 'debug') {
error_reporting((E_ALL ^ E_STRICT) & ~E_NOTICE); // Read: Show E_ALL, E_STRICT but NOT E_NOTICE.
}
//[internal callback function]: errorToExceptionHandler()
if(is_callable($serendipity['errorhandler'], false, $callable_name)) {
// set serendipity global error to exeption handler
if ($serendipity['production'] === 'debug') {
set_error_handler($serendipity['errorhandler'], error_reporting()); // Yes, DEBUG mode should actually report E_STRICT errors! In PHP 5.4s is contained in E_ALL already, but not in PHP 5.2.
} else {
// Caution! If we want to have the same noshow effect as upper set error_reporting(E_ALL) in 'debug' mode,
// do not clone it to set_error_handler(E_ALL), else everythimg is haltet to debug, which makes using debug obsolet.
set_error_handler($serendipity['errorhandler'], E_ALL & ~(E_NOTICE|E_STRICT));
}
}
define('IS_up2date', version_compare($serendipity['version'], $serendipity['versionInstalled'], '<='));
/*