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

Plugin update -all summary false positive "update" status

Open toshotosho opened this issue 4 years ago • 3 comments

Running

wp --allow-root plugin update --all

All updates except one succeeded. Nonetheless, the summary table at the end still says all plugins, including the failed one, were updated.

On next run, when no other plugins were updated successfully, the summary correctly reports an error. Output and environment info below.

root@localhost:/home/example/public_html# wp --allow-root plugin list --update=available
+--------------------------+----------+-----------+---------+
| name                     | status   | update    | version |
+--------------------------+----------+-----------+---------+
| enable-media-replace     | active   | available | 3.3.7   |
| github-updater           | active   | available | 9.2.2   |
| redirection              | active   | available | 4.6.2   |
| simple-custom-post-order | active   | available | 2.4.8   |
| sucuri-scanner           | active   | available | 1.8.22  |
| wp-live-chat-support     | inactive | available | 8.1.6   |
| wp-google-maps           | active   | available | 8.0.16  |
| wp-subtitle              | active   | available | 3.3.1   |
| wordpress-seo            | active   | available | 12.9.1  |
+--------------------------+----------+-----------+---------+
root@localhost:/home/example/public_html# wp --allow-root plugin update --all
Enabling Maintenance mode...
Downloading update from https://downloads.wordpress.org/plugin/enable-media-replace.zip...
Using cached file '/root/.wp-cli/cache/plugin/enable-media-replace-3.3.10.zip'...
Unpacking the update...
Installing the latest version...
Removing the old version of the plugin...
Plugin updated successfully.
Downloading update from https://api.github.com/repos/afragen/github-updater/zipball/9.3.2?access_token=934dcd25c6757f7260a3963540cbf2417a98114d...
Using cached file '/root/.wp-cli/cache/plugin/github-updater-9.3.2.2'...
Unpacking the update...
Warning: The package could not be installed. "PCLZIP_ERR_BAD_FORMAT (-10) : Invalid archive structure"
Downloading update from https://downloads.wordpress.org/plugin/redirection.zip...
Using cached file '/root/.wp-cli/cache/plugin/redirection-4.7.zip'...
Unpacking the update...
Installing the latest version...
Removing the old version of the plugin...
Plugin updated successfully.
... rest of plugins output says plugin updated successfully ...
Disabling Maintenance mode...
+--------------------------+-------------+-------------+---------+
| name                     | old_version | new_version | status  |
+--------------------------+-------------+-------------+---------+
| enable-media-replace     | 3.3.7       | 3.3.10      | Updated |
| github-updater           | 9.2.2       | 9.3.2       | Updated |
| redirection              | 4.6.2       | 4.7         | Updated |
| simple-custom-post-order | 2.4.8       | 2.4.9       | Updated |
| sucuri-scanner           | 1.8.22      | 1.8.24      | Updated |
| wp-live-chat-support     | 8.1.6       | 8.1.7       | Updated |
| wp-google-maps           | 8.0.16      | 8.0.19      | Updated |
| wp-subtitle              | 3.3.1       | 3.4         | Updated |
| wordpress-seo            | 12.9.1      | 13.1        | Updated |
+--------------------------+-------------+-------------+---------+
Success: Updated 9 of 9 plugins.
root@localhost:/home/example/public_html# wp --allow-root plugin list --update=available
+----------------+--------+-----------+---------+
| name           | status | update    | version |
+----------------+--------+-----------+---------+
| github-updater | active | available | 9.2.2   |
+----------------+--------+-----------+---------+
root@localhost:/home/example/public_html# wp --allow-root plugin update --all
Enabling Maintenance mode...
Downloading update from https://api.github.com/repos/afragen/github-updater/zipball/9.3.2?access_token=934dcd25c6757f7260a3963540cbf2417a98114d...
Using cached file '/root/.wp-cli/cache/plugin/github-updater-9.3.2.2'...
Unpacking the update...
Warning: The package could not be installed. "PCLZIP_ERR_BAD_FORMAT (-10) : Invalid archive structure"
Disabling Maintenance mode...
+----------------+-------------+-------------+--------+
| name           | old_version | new_version | status |
+----------------+-------------+-------------+--------+
| github-updater | 9.2.2       | 9.3.2       | Error  |
+----------------+-------------+-------------+--------+
Error: No plugins updated.


OS: Linux 4.4.0-145-generic #171-Ubuntu SMP Tue Mar 26 12:43:40 UTC 2019 x86_64
Shell:  /bin/bash
PHP binary: /usr/bin/php7.2
PHP version:  7.2.28-3+ubuntu16.04.1+deb.sury.org+1
php.ini used: /etc/php/7.2/cli/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: /home
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.4.0

toshotosho avatar Feb 29 '20 15:02 toshotosho

We've encountered this same issue with licensed plugins with an invalid/missing license, as it turns out, it seems to be related to the order the plugins are updated— if a previous plugin was successful, those that Error will be marked as Updated anyway.

Steps to Reproduce:

  • Install and activate a licensed plugin with an available update, but do not license the plugin.
  • update alongside another plugin that is alphabetically listed before the plugin

In the below example see the following:

  • When updated together (wp plugin update --all), advanced-custom-fields-pro fails, then akismet succeeds, then wp-migrate-db-pro reports false positive
  • Install an old version of advanced-custom-fields (now the first to be updated)
  • Run wp plugin update --all again, and see advanced-custom-fields-pro now also includes the false positive
$ wp plugin list
+-------------------------------+--------+-----------+---------+
| name                          | status | update    | version |
+-------------------------------+--------+-----------+---------+
| advanced-custom-fields-pro    | active | available | 5.9.3   |
| akismet                       | active | available | 3.1.5   |
| wp-migrate-db-pro             | active | available | 1.9.13  |
| wp-migrate-db-pro-media-files | active | available | 1.4.15  |
+-------------------------------+--------+-----------+---------+

$ wp plugin update --all --dry-run
Available plugin updates:
+-------------------------------+--------+---------+----------------+
| name                          | status | version | update_version |
+-------------------------------+--------+---------+----------------+
| advanced-custom-fields-pro    | active | 5.9.3   | 5.9.5          |
| akismet                       | active | 3.1.5   | 4.1.9          |
| wp-migrate-db-pro             | active | 1.9.13  | 1.9.14         |
| wp-migrate-db-pro-media-files | active | 1.4.15  | 1.4.16         |
+-------------------------------+--------+---------+----------------+

$ wp plugin update wp-migrate-db-pro
Enabling Maintenance mode...
Downloading update from https://api.deliciousbrains.com/?wc-api=delicious-brains&request=download&licence_key&slug=wp-migrate-db-pro&site_url=http://paidpluginerrors.local...
Using cached file '/Users/philtyler/.wp-cli/cache/plugin/wp-migrate-db-pro-1.9.14.'...
Unpacking the update...
Warning: The package could not be installed. "PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature"
Disabling Maintenance mode...
+-------------------+-------------+-------------+--------+
| name              | old_version | new_version | status |
+-------------------+-------------+-------------+--------+
| wp-migrate-db-pro | 1.9.13      | 1.9.14      | Error  |
+-------------------+-------------+-------------+--------+
Error: No plugins updated.

$ wp plugin update --all 
Enabling Maintenance mode...
Warning: Update package not available.
Downloading update from https://downloads.wordpress.org/plugin/akismet.4.1.9.zip...
Using cached file '/Users/philtyler/.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://api.deliciousbrains.com/?wc-api=delicious-brains&request=download&licence_key&slug=wp-migrate-db-pro&site_url=http://paidpluginerrors.local...
Using cached file '/Users/philtyler/.wp-cli/cache/plugin/wp-migrate-db-pro-1.9.14.'...
Unpacking the update...
Warning: The package could not be installed. "PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature"
Downloading update from https://api.deliciousbrains.com/?wc-api=delicious-brains&request=download&licence_key&slug=wp-migrate-db-pro-media-files&site_url=http://paidpluginerrors.local...
Using cached file '/Users/philtyler/.wp-cli/cache/plugin/wp-migrate-db-pro-media-files-1.4.16.'...
Unpacking the update...
Warning: The package could not be installed. "PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature"
Disabling Maintenance mode...
+-------------------------------+-------------+-------------+---------+
| name                          | old_version | new_version | status  |
+-------------------------------+-------------+-------------+---------+
| advanced-custom-fields-pro    | 5.9.3       | 5.9.5       | Error   |
| akismet                       | 3.1.5       | 4.1.9       | Updated |
| wp-migrate-db-pro             | 1.9.13      | 1.9.14      | Updated |
| wp-migrate-db-pro-media-files | 1.4.15      | 1.4.16      | Updated |
+-------------------------------+-------------+-------------+---------+
Error: Only updated 3 of 4 plugins.

$ wp plugin list
+-------------------------------+--------+-----------+---------+
| name                          | status | update    | version |
+-------------------------------+--------+-----------+---------+
| advanced-custom-fields-pro    | active | available | 5.9.3   |
| akismet                       | active | none      | 4.1.9   |
| wp-migrate-db-pro             | active | available | 1.9.13  |
| wp-migrate-db-pro-media-files | active | available | 1.4.15  |
+-------------------------------+--------+-----------+---------+

$ wp plugin install advanced-custom-fields --version=5.9.0
[...]
Success: Installed 1 of 1 plugins.

$ wp plugin update --all
Enabling Maintenance mode...
Downloading update from https://downloads.wordpress.org/plugin/advanced-custom-fields.5.9.5.zip...
Unpacking the update...
Installing the latest version...
Removing the old version of the plugin...
Plugin updated successfully.
Warning: Update package not available.
Downloading update from https://downloads.wordpress.org/plugin/akismet.4.1.9.zip...
Using cached file '/Users/philtyler/.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://api.deliciousbrains.com/?wc-api=delicious-brains&request=download&licence_key&slug=wp-migrate-db-pro&site_url=http://paidpluginerrors.local...
Using cached file '/Users/philtyler/.wp-cli/cache/plugin/wp-migrate-db-pro-1.9.14.'...
Unpacking the update...
Warning: The package could not be installed. "PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature"
Downloading update from https://api.deliciousbrains.com/?wc-api=delicious-brains&request=download&licence_key&slug=wp-migrate-db-pro-media-files&site_url=http://paidpluginerrors.local...
Using cached file '/Users/philtyler/.wp-cli/cache/plugin/wp-migrate-db-pro-media-files-1.4.16.'...
Unpacking the update...
Warning: The package could not be installed. "PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature"
Disabling Maintenance mode...
+-------------------------------+-------------+-------------+---------+
| name                          | old_version | new_version | status  |
+-------------------------------+-------------+-------------+---------+
| advanced-custom-fields        | 5.9.0       | 5.9.5       | Updated |
| advanced-custom-fields-pro    | 5.9.3       | 5.9.5       | Updated |
| akismet                       | 3.1.5       | 4.1.9       | Updated |
| wp-migrate-db-pro             | 1.9.13      | 1.9.14      | Updated |
| wp-migrate-db-pro-media-files | 1.4.15      | 1.4.16      | Updated |
+-------------------------------+-------------+-------------+---------+
Success: Updated 5 of 5 plugins.

$ wp plugin list
+-------------------------------+----------+-----------+---------+
| name                          | status   | update    | version |
+-------------------------------+----------+-----------+---------+
| advanced-custom-fields        | inactive | none      | 5.9.5   |
| advanced-custom-fields-pro    | active   | available | 5.9.3   |
| akismet                       | active   | none      | 4.1.9   |
| wp-migrate-db-pro             | active   | available | 1.9.13  |
| wp-migrate-db-pro-media-files | active   | available | 1.4.15  |
+-------------------------------+----------+-----------+---------+

pwtyler avatar Apr 02 '21 15:04 pwtyler

A shorter, easier test to reproduce:

# The incorrect behavior when the second of two updates errors
$ wp plugin install akismet --version=4.0 --force
$ wp plugin install wordpress-importer --version=0.5 --force
$ chmod -w wp-content/plugins/wordpress-importer
$ wp plugin update --all
# > See "Success: Updated 2 of 2 plugins."

$ chmod +w wp-content/plugins/wordpress-importer 

# The correct behavior when the first of two updates errors
$ wp plugin install akismet --version=4.0 --force
$ wp plugin install wordpress-importer --version=0.5 --force
$ chmod -w wp-content/plugins/akismet
$ wp plugin update --all
# > See "Error: Only updated 1 of 2 plugins."

Wrote a (failing) test for features/plugin-update.feature: https://github.com/pwtyler/extension-command/commit/94200361032e34b7100af2cc4caa8f8c0a4f2a8a

pwtyler avatar Apr 02 '21 17:04 pwtyler

Details on this being a bug in WordPress Core, not WP-CLI: https://core.trac.wordpress.org/ticket/53002

pwtyler avatar Apr 08 '21 19:04 pwtyler

This linked core fix was resolved with WP 5.9. WP-CLI could be patched to work around the behavior for earlier versions of WordPress, but I expect this issue could simply be closed as resolved upstream.

pwtyler avatar May 01 '23 19:05 pwtyler

Thanks for your perseverance and for letting me know, Phil. Completely forgot about this one.

toshotosho avatar May 01 '23 21:05 toshotosho