RFC: Change default of XH_debugmode()

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: RFC: Change default of XH_debugmode()

Post by cmb » Tue Apr 15, 2014 10:43 pm

Well, I believe changing the default of XH_debugmode() is neither sensible nor necessary for what I had in mind. Actually I was and still am concerned about fatal errors (E_ERROR, E_PARSE and may some more). As Holger had already pointed out, these would be shown, indepent of the user being logged in as admin, when the debug mode is enabled, but it is better to suppress such messages for security reasons ("don't reveal internals to outsiders"). So usually debug mode should be disabled on a production server.

The solution would be to avoid the particular error message, but to display that such a fatal error occured, and to instruct the user about the debug mode for further information (perhaps a link to our forum might be appropriate, too). This could be accomplished by registering a shutdown handler (as fatal errors can't be caught by an error handler), and to check whether there was a fatal error at all. A rough outline for insertion to cms.php (or maybe even better to the index.php's):

Code: Select all

function shutdown()
{
    $lastError = error_get_last();
    if (in_array($lastError['type'], array(E_ERROR, E_PARSE))) {
        echo 'A fatal error occured ...';
    }
}
if (function_exists('error_get_last')) {
    register_shutdown_function('shutdown');
}
As error_get_last() is available since PHP 5.2 only, users of older PHP version won't benefit, but those should better update anyway.

What do you think?
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: RFC: Change default of XH_debugmode()

Post by cmb » Tue Aug 12, 2014 1:40 pm

Done (r1332).
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply