Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-10-24 23:18:49

Plugin Author
Registered: 2008-06-01
Posts: 1,273

PHP display_errors

I’ve always believed that setting a site’s Production Status to Live results in all error messages being suppressed. From the help popup:

Live mode

No error reporting or diagnostic information will be sent to the page. Generally, Live mode is preferred, as it provides the best user experience and imposes the least overhead on the server.

So is there a reason I’m seeing PHP errors (such as parse messages) in Live mode, when TXP error messages are in fact suppressed?

The code in lib/txplib_misc.php suggests that the PHP display_errors setting is being explicitly enabled for Live mode:

function set_error_level($level)
    if ($level == 'debug') {
        error_reporting(E_ALL | E_STRICT);
    } elseif ($level == 'live') {
        // Don't show errors on screen.
        $suppress = E_NOTICE | E_USER_NOTICE | E_WARNING | E_STRICT | (defined('E_DEPRECATED') ? E_DEPRECATED : 0);
        error_reporting(E_ALL ^ $suppress);
        @ini_set("display_errors", "1");
    } else {
        // Default is 'testing': display everything except notices.
        error_reporting((E_ALL | E_STRICT) ^ (E_NOTICE | E_USER_NOTICE));

It makes the code comment // Don't show errors on screen. a little misleading!

To quote from the display_errors section on php.net:

This is a feature to support your development and should never be used on production systems (e.g. systems connected to the internet).


Board footer

Powered by FluxBB