wp-cli / extension-command

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

Fix fatal error in invalid plugin update offer #354

Closed danielbachhuber closed 1 year ago

danielbachhuber commented 1 year ago

Fixes https://github.com/wp-cli/extension-command/issues/292

I don't want to add feature tests for this because I don't want to pin tests to an outdated version of Elementor that probably won't survive WP and PHP version updates.

With the pull request:

$ wp plugin install elementor --version=3.1.4 --force
Installing Elementor Website Builder (3.1.4)
Success: Installed 1 of 1 plugins.
$ wp plugin update elementor --patch
Success: Plugin already updated.
$ wp plugin update elementor --minor
Plugin updated successfully.
+-----------+-------------+-------------+---------+
| name      | old_version | new_version | status  |
+-----------+-------------+-------------+---------+
| elementor | 3.1.4       | 3.11.2      | Updated |
+-----------+-------------+-------------+---------+
Success: Updated 1 of 1 plugins.

Without the pull request:

$ wp plugin install elementor --version=3.1.4 --force
Installing Elementor Website Builder (3.1.4)
Success: Installed 1 of 1 plugins.
$ wp plugin update elementor --patch
Fatal error: Uncaught UnexpectedValueException: Invalid version string "3.10.0-dev1" in /Users/danielbachhuber/projects/wp-cli-dev/vendor/composer/semver/src/VersionParser.php:186
Stack trace:
#0 /Users/danielbachhuber/projects/wp-cli-dev/vendor/composer/semver/src/Semver.php(39): Composer\Semver\VersionParser->normalize('3.10.0-dev1')
swissspidy commented 1 year ago

Surprised that the semver parser throws on this. 3.10.0-dev1 looks like something it's supposed to handle.