-
Notifications
You must be signed in to change notification settings - Fork 8
Add PHP version check for plugin. #123
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
Conversation
peterwilsoncc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks good to me.
As the plugin supports versions of WP that support PHP 5.6 or later, it would be good to check this file works with PHP 5.6 (while the others can use PHP 7.4 features). This will avoid white screening sites that don't run the correct version of PHP
In the linting workflow file's phpcs test, are you able to add a step to ensure it's maintained:
- name: Main file must support PHP 5.6
run: ./vendor/bin/phpcs --standard=PHPCompatibilityWP --runtime-set testVersion 5.5- ad-refresh-control.php|
@peterwilsoncc alternatively, what if we bump the PHP minimum to 7.4? |
Our minimum is already at 7.4. I think the concern here is that our minimum WordPress version is 5.7, which it supports PHP 5.6. So there's potential where someone might be able to install this plugin in an environment that is running PHP 5.6. We had a brief conversation about this on a different plugin and while I understand the potential issue, I don't think it's a big enough concern for us to spend time on. The whole reasoning behind adding these PHP checks in the first place was we've had some reports where we've bumped our PHP versions and someone was able to update the plugin even though their environment didn't meet the minimum requirements (which in theory WordPress is supposed to block). So we've been adding these to address what is hopefully already a small edge case. But it should be an even smaller edge case where someone is somehow currently running (or in the future running) our plugins in a PHP 5.6 environment (which we haven't claimed to support for a few years now) and then they happen to update said plugin and it whitescreens their site due to the main plugin file having things in it that don't work on PHP 5.6. Not saying that couldn't happen but I guess am saying it's not a scenario I'm concerned with. My suggestion is to ensure these PHP requirement checks do work on PHP 5.6+ (as that's easy enough to do) but I wouldn't go as far as linting the main plugin file separately or moving any core functionality into a different file and just leave the version checking in the main file (which is how we do this on Distributor). To me it's not worth the time investment to do that across all of our plugins. |
|
I'm also fine bumping the WP minimum to 6.2. |
Description of the Change
Add minimum version check for the plugin before loading it. This will ensure plugin update doesn't break the site that don't match our minimum PHP version.
Closes #122
How to test the Change
Changelog Entry
Credits
Props @dkotter, @rahulsprajapati
Checklist: