wp-cli / extension-command

Manages plugins and themes, including installs, activations, and updates.
MIT License
87 stars 80 forks source link

Malformed JSON Output - Error on plugin update #161

Open eckelarsson opened 5 years ago

eckelarsson commented 5 years ago

Hello,

When running wp plugin update --all --format=jsonand there is an error with updating a plugin the output is.

[{"name":"advanced-custom-fields-pro","old_version":"5.3.5","new_version":"5.7.13","status":"Error"},{"name":"wordpress-seo","old_version":"10.0","new_version":"10.0.1","status":"Updated"}]Error: Only updated 1 of 2 plugins.

The error is outside of the JSON format, should not be a mixed output.

Sysinfo

OS: Linux 4.4.0-127-generic #153-Ubuntu SMP Shell: PHP binary: /usr/bin/php7 PHP version: 7.2.13 php.ini used: /etc/php7/php.ini 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: /var/www/html WP-CLI packages dir: WP-CLI global config: WP-CLI project config: WP-CLI version: 2.1.0

ernilambar commented 4 months ago

This issue is still valid. I can reproduce this error in WP CLI 2.10 and WP 6.5.

wp plugin update --all --format=json

Output:

[{"name":"advanced-custom-fields-pro","old_version":"6.2.7","new_version":"6.2.9","status":"Error"}]Error: No plugins updated (1 failed).
ernilambar commented 4 months ago

I dug down a little and found that we have implemented Quiet logger for format with json and csv.

$logger = new Loggers\Quiet( WP_CLI::get_runner()->in_color() );
WP_CLI::set_logger( $logger );

But this https://github.com/wp-cli/wp-cli/blob/main/php/WP_CLI/Loggers/Quiet.php logger still produce output for error(). May be we need more quieter logger or something which will completely silence the output in error() also.