• Resolved fijisunshine

    (@fijisunshine)


    For security reasons, I’ve always disabled the function “error_reporting” in php.ini unless I’m debugging. Disabling this function works great in php 7.4 – WordPress doesn’t output error messages to the error log, it just outputs a message to the error log that error_reporting is disabled for security reasons.

    But in php 8.0, I’m getting this error:

    PHP Fatal error: Uncaught Error: Call to undefined function error_reporting() in … /wp-load.php:24

    In php 7.4, it wouldn’t be a fatal error. It would just say that error_reporting is disabled for security reasons.

    Any suggestions? Thank you

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator James Huff

    (@macmanx)

    Would you please report this following the steps at https://make.www.ads-software.com/core/handbook/testing/reporting-bugs/ ?

    Thanks!

    Dion

    (@diondesigns)

    Welcome to the wild, wonderful world of PHP 8.0. Unlike all previous versions of PHP, if you disable a function, it will no longer exist. That’s why you received the fatal error.

    PHP 8.0 is breaking countless numbers of websites where hosting companies or site owners disabled functions for “security reasons”. (In most cases it was stupid to disable the functions, but I digress.) This is in addition to the equally-curious decision in PHP 8.0 to disable error suppression in many functions when @ is used — which is causing a lot of headaches to developers of PHP frameworks…

    Between the above and opcache JIT not being particularly stable, it’s best to stay away from PHP 8.0 for now.

    Moderator James Huff

    (@macmanx)

    We should still find a way to fail gracefully though, hence the request to open an official bug report.

    Dion

    (@diondesigns)

    The problem is that, with @ no longer able to suppress fatal errors, it’s not possible to fail gracefully in PHP 8.0 when a disabled function is called. I truly hope the PHP devs come to their senses and revert what they did with @. (Especially since it doesn’t work as advertised — try @include on a non-existent file, PHP 8.0 throws a warning when supposedly only fatal errors are not suppressed.)

    Having said this, IMO this isn’t a WordPress issue. If someone disables a PHP core function, it’s up to that person to deal with the ramifications. Otherwise WordPress would be bloated with tens of thousands of if(function_exists('a_function')) conditionals…

    Thread Starter fijisunshine

    (@fijisunshine)

    Thank you James and Dion for your excellent feedback. As James suggested, I’ve reported it as a bug.

    The trac ticket is #52226 for anyone following along.

    A minor change and reply is sitting on the ticket but to repeat the advice about disabling PHP Core functions on customised systems: when disabling core PHP functions in the php.ini file it’s probably best to add a dummy version in your wp-config.php file so fatal errors don’t occur within WordPress, themes or plugins.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PHP 8 issue: Fatal error when error_reporting is disabled’ is closed to new replies.