Repository: wp-cli/wp-cli

Issue #3220: Respect WP_DEBUG instead of overriding
Created: 2016-08-01T16:52:59Z
Currently the value of display_errors is overridden by \Utils\wp_debug_mode(), but I would expect WP_CLI to respect the value set by WP_DEBUG  and \wp_debug_mode() instead.
It sounds like there may have once been a reason for overriding it, but it's not known anymore.
In my experience, having it overridden is a hassle, because when I'm writing commands I don't have notice/warning/error messages easily available. In many cases, it might not even be obvious that an error occurred at all. So I have to manually check log files or use a fragile workaround to restore the original settings.
I'd be happy to work on a PR if it's decided that this behavior should be removed.
Background information:
php/utils-wp.php#L26
cb57cc0
#786

Duplicate issue #5945: PHP Errors not being reported
Created: 2024-05-03T21:35:25Z
Bug Report

 Yes, I reviewed the contribution guidelines.
 Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.

Describe the current, buggy behavior
When any command is run and PHP throws and error, the command fails silently without any information on the error. This happens when:

Parse error
Exception is thrown.
Possibly others.

I tracked the issue down to the \WP_CLI\Utils\wp_debug_mode function. Specifically, this line.
ini_set( 'display_errors', function_exists( 'xdebug_debug_zval' ) ? false : 'STDERR' );
If I remove the line, PHP errors are restored and information is available on the console.
My hunch is when Xdebug updated to version 3, the way it is loaded changed to make the xdebug_debug_zval always available and therefore disabled in error display. I don't have the original context for why the code was done this way so it is only a hunch.
The issue may only happen on specific environments depending on how xdebug is configured.
Here is how xdebug is configured on my machine.
zend_extension = php_xdebug.dll
xdebug.mode = debug,develop
xdebug.start_with_request = trigger
xdebug.client_host = 127.0.0.1
xdebug.output_dir = E:\xdebug-profile
xdebug.profiler_output_name = %R
xdebug.trace_output_name = %R
Describe how other contributors can replicate this bug

Change any PHP code in the project running a command to introduce a parse error. A simple xxxx somewhere in the PHP code should do it.
Run any command.
Observe no PHP information is provided.

Describe what you expect as the correct outcome
PHP errors displayed in the console.
Let us know what environment you are running this on
OS:     Windows NT 10.0 build 19045 (Windows 10) AMD64
Shell:  D:\Git\usr\bin\bash.exe
PHP binary:     D:\xampp\php-8.3\php.exe
PHP version:    8.3.6
php.ini used:   D:\xampp\php-8.3\php.ini
MySQL binary:
MySQL version:
SQL modes:
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       E:\SVN\starting-point
WP-CLI packages dir:
WP-CLI cache dir:       C:\Users\mat/.wp-cli/cache
WP-CLI global config:   C:\Users\mat/.wp-cli/config.yml
WP-CLI project config:
WP-CLI version: 2.10.0-windows


Provide a possible solution
I have included a patch for specific changes which appear to work.
fix-error-display.patch

Closing comment (2024-05-07T12:47:26Z): Thanks for the report, @mlipe-nxs !
I think this is a duplicate of #3220. Can we close this issue in favor of that one?