Skip to content

PHP error reporting

Output from PHP error reporting can be helpful for debugging issues in application code.

Settings for reporting levels

PHP error reporting levels for WordPress environments on the VIP Platform are defined by platform-level settings, WordPress Core, and custom settings added to application code. 

A php.ini configuration file sets a default for all PHP error reporting to be enabled for a WordPress environment except for notices, deprecation notices, and strict notices:
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT

Though E_STRICT is included, it is redundant in this setting since PHP 7 reassigned all instances of E_STRICT to other levels.

When WordPress loads, it updates the PHP error reporting settings to enable:
E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR.

Based on the PHP error reporting settings with WordPress loaded, if echo error_reporting() was called in application code with no arguments, the reporting level value 4983 would be returned.

Error report output

The default values of WordPress debugging constants can be overridden and set per-environment by defining the constants with the desired values in vip-config/vip-config.php of the branch deploying to that environment.

On VIP, WP_DEBUG_LOG is set to false and cannot be overridden.

By default,WP_DEBUG_DISPLAY and WP_DEBUG are not defined and as a result, will load as false unless overridden.

Even if overridden and defined as true, WP_DEBUG_DISPLAY (and WP_DEBUG_LOG) will perform no function unlessWP_DEBUG is also defined as true.

When WP_DEBUG is defined as true, WordPress sets E_ALL (all errors, warnings, and notices). If WP_DEBUG_DISPLAY is also defined as true, the ini setting display_errors will be enabled, and error output will appear in the rendered page HTML.

For this reason, WP_DEBUG is defined as false on production environments, and configurations should not be set to enable WP_DEBUG_DISPLAY unless the production environment is unlaunched.

On local environments and non-production environments, WP_DEBUG is defined as true in the VIP Skeleton codebase to make PHP Deprecations, Notices, Warnings, and Errors available during development.

Other than the situational exceptions described above, there are no differences between error reporting levels for production or non-production environments—launched or unlaunched—or between environments running PHP 7.4, 8.0, or 8.1.

Logging

For WP_DEBUG_LOG to function as expected, both WP_DEBUG_LOG and WP_DEBUG must be defined as true.

If both WP_DEBUG_LOG and WP_DEBUG are defined as true (or assigned a string value) in a VIP Platform environment’s vip-config.php, logged error output will be retrievable in the VIP Dashboard Health: Logs panel or with the VIP-CLI Runtime Logs command.

Last updated: July 20, 2022