What is ExpressionEngine doing that you expect it not to be doing?
When a PHP “error” (notice, warning, etc) occurs, EE outputs the error in HTML to the user’s web browser. Since I have explicitly turned off user-visible error output (see below for how), I would expect that these errors would not be output.
Where do you expect to be able to change the behavior you are seeing and where have you made adjustments to effect that change?
Primarily, php.ini settings (actually set via ini_set before the EE loader gets executed). Here’s what that looks like for my set up:
define('SITE_STATUS', 'prod');
ini_set('session.save_path', '/usr/home/username/tmp/sess/');
ini_set('display_startup_errors', 'off');
ini_set('display_errors', 'off');
ini_set('html_errors', 'off');
ini_set('log_errors', 'on');
ini_set('ignore_repeated_errors', 'off');
ini_set('ignore_repeated_source', 'off');
ini_set('report_memleaks', 'on');
ini_set('track_errors', 'on');
ini_set('docref_root', '0');
ini_set('docref_ext', '0');
ini_set('error_log', '/usr/home/username/h/ee2_svn/logs/php.log');
ini_set('error_reporting', '-1');
ini_set('log_errors_max_len', '0');
ini_set('xdebug.collect_params', '0');
The above code is included at the top of the site’s public index.php. I can verify all settings are taking effect by checking phpinfo().
In addition to the above, I have debug = 0 set in index.php and I have $config[‘debug’] = 0 set in config.php, as noted above in this thread.
The only other change I’ve made is on line 180 of the EE public index.php. Here’s the relevant section and then my modification:
ORIGINAL:
/*
* --------------------------------------------------------------------
* Set the error reporting level
* --------------------------------------------------------------------
*/
if (DEBUG == 1)
{
error_reporting(E_ALL);
@ini_set('display_errors', 1);
}
else
{
error_reporting(0); // this line is what changes
}
MY CHANGE:
/*
* --------------------------------------------------------------------
* Set the error reporting level
* --------------------------------------------------------------------
*/
if (DEBUG == 1)
{
error_reporting(E_ALL);
@ini_set('display_errors', 1);
}
else
{
error_reporting(error_reporting()); // this is the changed line
}
I made this change because I want my error_reporting level preserved. I don’t want to have to enable debug mode in order to get PHP error logging.
Here’s the code and comments that determine if EE should show the HTML error or not:
system/codeigniter/system/core/Common.php:~449
// Should we display the error? We'll get the current error_reporting
// level and add its bits with the severity bits to find out.
if (($severity & error_reporting()) == $severity)
{
$_error->show_php_error($severity, $message, $filepath, $line);
}
It would seem that EE is only checking if my error_reporting level is high enough to catch this particular error. Since I want to log all errors I have error reporting set to -1.
What behavior would you like to see from ExpressionEngine as it relates to this issue?
As noted at the top of this thread, changing the if clause to ini_get display_errors fixes this issue for me. My thinking is that if I have gone to the trouble to turn off errors displaying to my users, EE should abide by that setting.
An interesting side effect of using an error handler is also occuring… Any php function prepended with the @ error suppression character does not actually get its error level suppressed. This is because errors still get sent to the error handler, regardless of the @ sign.
I do not make it a practice of supressing errors with the @ character, but many, many third party plugins do for things such as fopen, etc. All of these supposed-to-be-suppressed errors get output to the browser as well, due to the error handler.
I hope this helps explain my problem.
Thanks for sticking with me.
Ian