Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp plugin update fails badly on unparsable tags #274

Closed
2 tasks done
drzraf opened this issue Dec 11, 2020 · 3 comments · Fixed by wp-cli/wp-cli#5894
Closed
2 tasks done

wp plugin update fails badly on unparsable tags #274

drzraf opened this issue Dec 11, 2020 · 3 comments · Fixed by wp-cli/wp-cli#5894

Comments

@drzraf
Copy link

drzraf commented Dec 11, 2020

Bug Report

Describe the current, buggy behavior

wp plugin update fails badly if a repository provide unparsable tags.

Describe how other contributors can replicate this bug

  • Install wp-maintenance-mode 2.2.x (It's important to be below the maximum release. 2.2.4 for example)
  • Run wp @ae plugin update --patch wp-maintenance-mode
  • Encounter an error Uncaught UnexpectedValueException: Invalid version string "psd-files". (See below for the full stacktrace)

Describe what you would expect as the correct outcome

Update (patch release) to work.

Let us know what environment you are running this on

OS:	Linux 4.19.0-12-cloud-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64
Shell:	/bin/bash
PHP binary:	/usr/bin/php7.4
PHP version:	7.4.12
php.ini used:	/etc/php/7.4/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:	/etc/cron.d
WP-CLI packages dir:	
WP-CLI global config:	~/.wp-cli/config.yml
WP-CLI project config:	
WP-CLI version:	2.4.0

(Using Bedrock)

Provide a possible solution

  • I suggest to catch errors from Composer\Semver\Semver::satisfies().
  • I suggest to output the plugin which actually failed. That would spare command-line run/bissecting time (The string psd-files is nowhere on the filesystem. Not even ~/.composer/cache).

Provide additional context/Screenshots

https://plugins.svn.wordpress.org/wp-maintenance-mode/tags/
Shows that a psd-files tags was added.
When wp-maintenance-mode is at the latest version already, it seems the psd-files tag is omitted.
But if not, then it triggers an error at /composer/semver/src/VersionParser.php:172 which is not caught.

PHP Fatal error:  Uncaught UnexpectedValueException: Invalid version string "psd-files" in phar:///usr/local/bin/wp/vendor/composer/semver/src/VersionParser.php:172
Stack trace:
#0 phar:///usr/local/bin/wp/vendor/composer/semver/src/Semver.php(39): Composer\Semver\VersionParser->normalize()
#1 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/utils.php(785): Composer\Semver\Semver::satisfies()
#2 phar:///usr/local/bin/wp/vendor/wp-cli/extension-command/src/WP_CLI/CommandWithUpgrade.php(583): WP_CLI\Utils\get_named_sem_ver()
#3 phar:///usr/local/bin/wp/vendor/wp-cli/extension-command/src/WP_CLI/CommandWithUpgrade.php(342): WP_CLI\CommandWithUpgrade->get_minor_or_patch_updates()
#4 phar:///usr/local/bin/wp/vendor/wp-cli/extension-command/src/Plugin_Command.php(640): WP_CLI\CommandWithUpgrade->update_many()
#5 [internal function]: Plugin_Command->update()
#6 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(98): call_user_func()
#7 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\ in phar:///usr/local/bin/wp/vendor/composer/semver/src/VersionParser.php on line 172
Fatal error: Uncaught UnexpectedValueException: Invalid version string "psd-files" in phar:///usr/local/bin/wp/vendor/composer/semver/src/VersionParser.php:172
Stack trace:
#0 phar:///usr/local/bin/wp/vendor/composer/semver/src/Semver.php(39): Composer\Semver\VersionParser->normalize()
#1 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/utils.php(785): Composer\Semver\Semver::satisfies()
#2 phar:///usr/local/bin/wp/vendor/wp-cli/extension-command/src/WP_CLI/CommandWithUpgrade.php(583): WP_CLI\Utils\get_named_sem_ver()
#3 phar:///usr/local/bin/wp/vendor/wp-cli/extension-command/src/WP_CLI/CommandWithUpgrade.php(342): WP_CLI\CommandWithUpgrade->get_minor_or_patch_updates()
#4 phar:///usr/local/bin/wp/vendor/wp-cli/extension-command/src/Plugin_Command.php(640): WP_CLI\CommandWithUpgrade->update_many()
#5 [internal function]: Plugin_Command->update()
#6 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(98): call_user_func()
#7 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\ in phar:///usr/local/bin/wp/vendor/composer/semver/src/VersionParser.php on line 172
Error: There has been a critical error on your website.Learn more about debugging in WordPress. There has been a critical error on your website
@drzraf
Copy link
Author

drzraf commented May 17, 2021

It's happening again (I guess wp-maintenance-mode produced a new major release) and blocks wp plugin update

@schlessera
Copy link
Member

I can't replicate this currently. It looks like the misformed tag was removed again, so I assume this also does create problems in other areas of the WP.org ecosystem.

Nevertheless, I agree that the code needs to be more robust to fail gracefully if unexpected data is fed to it.

@ypcs
Copy link

ypcs commented Sep 12, 2022

This same bug occurs with eg. Elementor plugin, see elementor/elementor#13090 .

I have a proposal for a fix in https://github.com/Seravo/wp-cli/commit/a148282d16d14c42e35c722cf0fe9f156b94389c , didn't yet open a PR however as I don't currently have time to make this commit compatible with PR guidelines described at https://make.wordpress.org/cli/handbook/contributions/pull-requests/ .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants