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

Add a PHP version check and disable functionality if a site doesn't meet requirements #129

Merged
merged 2 commits into from
Jul 26, 2023

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Jul 24, 2023

Description of the Change

In the last release we bumped the minimum PHP version to 8.0. What we've found in the past is that sometimes sites are able to bypass the restrictions WordPress has in place around minimum versions and end up getting fatal errors when their site doesn't meet the requirements (for example, they may be running PHP 7.4 and somehow are able to install the latest version of the plugin which requires PHP 8.0, resulting in a fatal error).

This PR helps resolve that by adding a check before we load any of our plugin functionality. If a site doesn't meet our minimum requirements (in this case, PHP < 8.0) we output an admin notice and we don't load any more functionality.

Closes #125

How to test the Change

  1. Checkout the develop branch and run npm run build-release
  2. Create an environment running PHP 8.0+
  3. Install and activate the plugin and note that things work
  4. Downgrade the PHP version on that environment to 7.4
  5. Note a fatal error is encountered
  6. Checkout this branch and run npm run build-release again
  7. Ensure the plugin shows an admin notice when running PHP 7.4 and works as expected with PHP 8.0+

Changelog Entry

Added - More robust minimum PHP version check.

Credits

Props @dkotter

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

…dmin notice and don't run any plugin functionality
@dkotter dkotter added this to the 1.2.1 milestone Jul 24, 2023
@dkotter dkotter self-assigned this Jul 24, 2023
@dkotter dkotter requested review from a team and dsawardekar as code owners July 24, 2023 22:40
@dkotter dkotter requested review from ravinderk and removed request for a team July 24, 2023 22:40
@dkotter
Copy link
Collaborator Author

dkotter commented Jul 24, 2023

@ravinderk Hoping to get a 1.2.1 release out here soon that contains that trailing comma fix. I think this would be good to go out with it as well so hoping you have a few minutes to review.

@dkotter dkotter mentioned this pull request Jul 24, 2023
16 tasks
ravinderk
ravinderk previously approved these changes Jul 26, 2023
Copy link
Contributor

@ravinderk ravinderk left a comment

Choose a reason for hiding this comment

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

@dkotter This pull request is looking good.

Addition Request -
Can we set the PHP version to 8.0 in the plugin header information and readme.txt?

* Requires PHP: 8

Requires PHP: 7.4

@dkotter dkotter merged commit 9527bce into develop Jul 26, 2023
8 checks passed
@dkotter dkotter deleted the fix/php-version-check branch July 26, 2023 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add PHP checks
2 participants