Per the comment from Alexey below, PHP 8.0 changes the behaviour of disable_functions to make disabled functions undefined, thus creating a fatal error. You can probably define a basic
function error_reporting() which just returns
true, in wp_config.php, but I haven’t tried this.
Don’t get me wrong. I like WordPress as a product. It does a job and it does it fairly well. But here endeth the praise.
WordPress’s codebase is, to put it politely, a fucking shit-show. In the codebase of this very blog you’re reading now, there are no fewer than 46 references to error_reporting across WordPress core and plugins.
By default, WordPress will log the following, unless of course a plugin or some other voodoo-magic changes it:
E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR
What’s slightly annoying about this is the fact it logs warnings. Given the aforementioned shit-show-ness of the WordPress code base and the plugins that attach to it, it tends to log a fair few warnings, thus flooding your log files with junk
There doesn’t seem to be a nice way to change this, without hacking WordPress’s core code. You can add a call to error_reporting() in wp-config.php but it gets overridden some time later during WP loading. You can create a plugin which changes it but some other plugin is inevitably going to change it back again and it’s already logged core warnings by this point.
PHP has a disable_functions setting. Do you see where I’m going with this? 😉
If you add error_reporting to the end of the list of the disable_functions setting in your php.ini then WordPress can no longer change error_reporting settings and, thus, the setting provided in your php.ini will be honoured.
The big downside of this is that if you’re running something other than WordPress on your server, it also cannot do error_reporting(). This probably isn’t a big deal because changing error reporting levels at runtime is, frankly, fucking annoying. If, for whatever reason you do need to do this, you could create a separate php-fpm pool for WordPress and pass the modified disable_functions value to that pool like so:
php_admin_value[disable_functions] = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,error_reporting,
The other possible downside is that there may be a scenario where WordPress’s changing of error_reporting is useful. I’m not sure what this is but I’m imagining a scenario where loading a plugin throws an error and it can catch this and display it to you in the wp-admin UI. If this were the case (I’ll update this blog post if ever I find it to be…) then you can create a separate FPM pool for /wp-admin/* and not disable error_reporting there. If you were to do this, you should remember that /wp-admin/admin-ajax.php can be called by plugins on the main site and isn’t actually anything to do with the administration of your site (did I say how much of a shit-show WordPress is?) so you need to assign this file to the main pool and not the pool of your /wp-admin/*.
Clear? Cool. Enjoy <3