wp-cli / wp-cli

⚙️ WP-CLI framework

Home Page:https://wp-cli.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP Errors not being reported

mlipe-nxs opened this issue · comments

Bug Report

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:

  1. Parse error
  2. Exception is thrown.
  3. 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

Thanks for the report, @mlipe-nxs !

I think this is a duplicate of #3220. Can we close this issue in favor of that one?

Yes. Make sense to only have one thread. :-)