' . "\n"; } /** * Set our own exeption handler to convert all errors into exeptions automatically * function_exists() avoids 'cannot redeclare previously declared' fatal errors in XML feed context. * * See Notes about returning false * * @access public * @param standard * @return null */ if (!function_exists('errorToExceptionHandler')) { function errorToExceptionHandler($errNo, $errStr, $errFile = '', $errLine = NULL, $errContext = array()) { global $serendipity; $rep = ini_get('error_reporting'); $args = func_get_args(); // 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 if ($rep == 0) { return false; } // if not using Serendipity testing and user or ISP has set PHPs display_errors to show no errors at all, respect if ($serendipity['production'] === true && ini_get('display_errors') == 0) { return false; } // Several plugins might not adapt to proper style. This should not completely kill our execution. if ($serendipity['production'] !== 'debug' && preg_match('@Declaration.*should be compatible with@i', $args[1])) { #if (!headers_sent()) echo "Compatibility warning: Please upgrade file old '{$args[2]}', it contains incompatible signatures.
Details: {$args[1]}
"; return false; } // any other errors go here - throw errors as exception if ($serendipity['production'] === 'debug') { // We don't want the notices - but everything else ! echo ' == FULL DEBUG ERROR MODE == '; echo '
';
            // trying to be as detailled as possible - but beware using args containing sensibel data like passwords
            if (function_exists('debug_backtrace') && version_compare(PHP_VERSION, '5.3.6') >= 0) {
                if ( version_compare(PHP_VERSION, '5.4') >= 0 ) {
                    $debugbacktrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 8);
                } else {
                    $debugbacktrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
                }
                print_r($debugbacktrace);
            }
            //print_r($args); // debugging [Use with care! Not to public, since holding password and credentials!!!]
            // debugbacktrace is nice, but additional it is good to have the verbosity of SPL EXCEPTIONS, except for db connect errors
            // compare version to not get strange T_NEW parse errors (http://board.s9y.org/viewtopic.php?f=10&t=19436)
            if (!$serendipity['dbConn'] || version_compare(PHP_VERSION, '5.3', '<')) {
                echo '

' . $errStr . ' in ' . $errFile . ' on line ' . $errLine . '

'; } else { throw new ErrorException($errStr); // tracepath = all, if not ini_set('display_errors', 0); } echo '
'; // if using throw new ... this ending tag will not be send and displayed, but it still looks better and browsers don't really care exit; // make sure to exit in case of database connection errors. } if ($serendipity['production'] === false) { echo ' == TESTING ERROR MODE == '; echo '
';
            // see notes above
            if (!$serendipity['dbConn'] || version_compare(PHP_VERSION, '5.3', '<')) {
                echo '

' . $errStr . ' in ' . $errFile . ' on line ' . $errLine . '

'; } else { throw new ErrorException($errStr); // tracepath = all, if not ini_set('display_errors', 0); } echo '
'; // if using throw new ... this ending tag will not be send and displayed, but it still looks better and browsers don't really care exit; // make sure to exit in case of database connection errors. } if ($serendipity['production'] === true) { if( $serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN ) { // ToDo: enhance for more special serendipity error needs $str = " == SERENDIPITY ERROR == "; $str .= '

' . $errStr . ' in ' . $errFile . ' on line ' . $errLine . '

'; #var_dump(headers_list()); if (headers_sent()) { serendipity_die($str); // case HTTP headers: needs to halt with die() here, else it will path through and gets written underneath blog content, which hardly isn't seen by many users } else { // see global include of function in plugin_api.inc.php // this also reacts on non eye-displayed errors with following small javascript, // while being in tags like