extension-command icon indicating copy to clipboard operation
extension-command copied to clipboard

`wp plugin update --all` reports incorrect result information returned if one plugin update fails

Open afragen opened this issue 4 years ago • 3 comments

Bug Report

Describe the current, buggy behavior

In reviewing #53002 the result shows with a Success message for both plugins when it should be for only one.

$ wp plugin update --all                         
Downloading update from https://downloads.wordpress.org/plugin/akismet.4.1.9.zip...
Using cached file '/Users/afragen/.wp-cli/cache/plugin/akismet-4.1.9.zip'...
Unpacking the update...
Installing the latest version...
Removing the old version of the plugin...
Plugin updated successfully.
Downloading update from https://downloads.wordpress.org/plugin/wordpress-importer.0.7.zip...
Using cached file '/Users/afragen/.wp-cli/cache/plugin/wordpress-importer-0.7.zip'...
Unpacking the update...
Installing the latest version...
Removing the old version of the plugin...
Warning: Could not remove the old plugin.
Plugin update failed.
+--------------------+-------------+-------------+---------+
| name               | old_version | new_version | status  |
+--------------------+-------------+-------------+---------+
| akismet            | 4.0         | 4.1.9       | Updated |
| wordpress-importer | 0.5         | 0.7         | Updated |
+--------------------+-------------+-------------+---------+
Success: Updated 2 of 2 plugins.

Describe how other contributors can replicate this bug

Follow steps in #53002 to replicate.

Describe what you would expect as the correct outcome

I would expect the result message should report only 1 of 2 plugins updated and report the failure in the table.

Let us know what environment you are running this on

Local 5.10.5

OS:	Darwin 20.5.0 Darwin Kernel Version 20.5.0: Sat May  8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 x86_64
Shell:	/bin/zsh
PHP binary:	/Applications/Local.app/Contents/Resources/extraResources/lightning-services/php-7.3.5+10/bin/darwin/bin/php
PHP version:	7.3.5
php.ini used:	/Users/afragen/Library/Application Support/Local/run/sZcwhkZ6P/conf/php/php.ini
MySQL binary:	/Applications/Local.app/Contents/Resources/extraResources/lightning-services/mysql-8.0.16+6/bin/darwin/bin/mysql
MySQL version:	mysql  Ver 8.0.16 for macos10.14 on x86_64 (MySQL Community Server - GPL)
SQL modes:	ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
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:	/Users/afragen/Local_Sites/wpclierrror/app/public
WP-CLI packages dir:	
WP-CLI global config:	/Applications/Local.app/Contents/Resources/extraResources/bin/wp-cli/config.yaml
WP-CLI project config:	
WP-CLI version:	2.5.0

afragen avatar Jun 10 '21 18:06 afragen

Related/duplicate: https://github.com/wp-cli/extension-command/issues/216

pwtyler avatar Jun 11 '21 19:06 pwtyler

I think #216 is originally related to non-dot org plugin updates. The error encountered is usually an authentication error and likely an invalid personal access token.

afragen avatar Jun 11 '21 19:06 afragen

The root cause of why the update didn't apply is different (i.e. auth failure vs write access), but the behavior is the same— WP-CLI reports the wrong status after the update failed to apply, because of the faulty info returned from Core.

I initially encountered this because of authentication (missing credentials on a development environment), hence my convoluted example in the linked thread with ACF/Migrate DB Pro, but then realized it could be replicated much faster with chmod 😁

pwtyler avatar Jun 11 '21 20:06 pwtyler

I think this is now working as expected:

$ chmod 555 wp-content/plugins/one-time-login
$ wp plugin update --all
Downloading update from https://downloads.wordpress.org/plugin/one-time-login.0.4.0.zip...
Using cached file '/Users/danielbachhuber/.wp-cli/cache/plugin/one-time-login-0.4.0.zip'...
The authenticity of one-time-login.0.4.0.zip could not be verified as no signature was found.
Unpacking the update...
Installing the latest version...
Removing the old version of the plugin...
Warning: Could not remove the old plugin.
Plugin update failed.
Downloading update from https://downloads.wordpress.org/plugin/wordpress-importer.0.8.1.zip...
Using cached file '/Users/danielbachhuber/.wp-cli/cache/plugin/wordpress-importer-0.8.1.zip'...
The authenticity of wordpress-importer.0.8.1.zip could not be verified as no signature was found.
Unpacking the update...
Installing the latest version...
Removing the old version of the plugin...
Plugin updated successfully.
+--------------------+-------------+-------------+---------+
| name               | old_version | new_version | status  |
+--------------------+-------------+-------------+---------+
| one-time-login     | 0.3.1       | 0.4.0       | Error   |
| wordpress-importer | 0.8         | 0.8.1       | Updated |
+--------------------+-------------+-------------+---------+
Error: Only updated 1 of 2 plugins (1 failed).

danielbachhuber avatar Sep 08 '23 18:09 danielbachhuber

Yep this was resolved with WP 5.9.

pwtyler avatar Sep 08 '23 19:09 pwtyler

@pwtyler Thanks for your work on that other thread!

danielbachhuber avatar Sep 08 '23 22:09 danielbachhuber