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

Check WordPress and PHP requirements before installing a theme or plugin #436

Merged
merged 10 commits into from
Dec 13, 2024

Conversation

mrsdizzie
Copy link
Member

This matches the behavior of WordPress core which will refuse to install a plugin if the local copy of WordPress or PHP don't meet the minimum requirements for the most recent version as listed by the plugin authors.

Unfortunately the api is limited and only provides these requirement details for the most recent version, so it isn't possible to find an older version that might work. As a compromise, this code doesn't check requirements if a user provides a specific --version since we can't know the requirements for anything other than the latest version and assume if somebody specifies a version they know it will work or want to try anyway.

This matches the behavior of WordPress core which will refuse to install
a plugin if the local copy of WordPress or PHP don't meet the minimum
requirements for the most recent version as listed by the plugin
authors.

Unfortunately the api is limited and only provides these requirement
details for the most recent version, so it isn't possible to find an
older version that might work. As a compromise, this code doesn't check
requirements if a user provides a specific --version since we can't know
the requirements for anything other than the latest version and assume
if somebody specifies a version they know it will work or want to try
anyway.
@mrsdizzie
Copy link
Member Author

For reference, this is what it looks like trying to install a plugin that doesn't meet requirements in the WordPress dashboard:

Screenshot 2024-12-06 at 13 22 22

The built in wp functions for this are too new (Added in 5.2)
@mrsdizzie
Copy link
Member Author

Interesting, this now reveals issues with existing tests like:

Warning: akismet: This plugin does not work with your version of WordPress. Minimum WordPress requirement is 5.8

When running the WordPress 3.7 test. Several similar errors in the WordPress 6.2 test as many of the plugins we use for the tests actually require newer versions of WordPress.

If the PR seems OK otherwise I can fix those, either by finding new plugins or just by specifying a specific plugin version for those tests (which bypasses this new check).

src/Plugin_Command.php Outdated Show resolved Hide resolved
Similar to what would happen in is_wp_version_compatible()
Try and only test these with supported wp versions on unsupported php
@swissspidy
Copy link
Member

Should we perhaps add an --ignore-requirements arg? As long as you don't activate the plugin/theme, installing an incompatible version is not a problem.

This will also be relevant for #407 (plugin dependencies).

Per code review, also offer --ignore-requirements as a way to install
themes and plugins that don't meet the listed requirements
@mrsdizzie
Copy link
Member Author

Should we perhaps add an --ignore-requirements arg? As long as you don't activate the plugin/theme, installing an incompatible version is not a problem.

This will also be relevant for #407 (plugin dependencies).

Sounds good, I added that arg. The only thing left is what to do about failing tests on WP 3.7 and WP 6.2. They are all for the same reason that the plugins we use for these tests have a higher WP requirement and now wp plugin/theme install fails with an appropriate error.

@swissspidy
Copy link
Member

The tests involving wporg_last_updated are really flaky right now, so I'm ignoring those failures for now.

Copy link
Member

@swissspidy swissspidy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@swissspidy swissspidy merged commit e0abcdd into wp-cli:main Dec 13, 2024
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants