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 check to ensure we have a valid PHP version #111

Merged
merged 4 commits into from
Apr 5, 2023

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Mar 24, 2023

Description of the Change

The minimum PHP version was bumped in #82 which went out in the v2.1.0 release. We've had a few reports of users running a version of PHP less than 7.4 that have somehow been able to update to the latest version of the plugin (ideally WordPress would prevent this but that's another issue to solve).

Because of the new PHP version we set in our composer.json file, composer is throwing a fatal error in those situations. Ideally we should never throw fatal errors, so this PR fixes this by adding a PHP version check that renders an admin error message and disables the rest of the plugin from functioning.

Screen Shot 2023-03-24 at 11 00 54 AM

Closes #110

How to test the Change

  1. Setup a WordPress environment running PHP 7.3
  2. Install the v2.1.0 of Safe SVG and see a fatal error happen
  3. Update Safe SVG to this branch and note no fatal error should happen but an admin error message should show

Changelog Entry

Fixed - Better error handling for environments that don't match our minimum PHP version

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.

…in functionality. Output an error message if needed.
@dkotter dkotter requested a review from a team as a code owner March 24, 2023 17:00
@dkotter dkotter self-assigned this Mar 24, 2023
@dkotter dkotter requested review from iamdharmesh and removed request for a team March 24, 2023 17:00
@dkotter dkotter requested a review from ravinderk March 24, 2023 18:20
@dkotter dkotter added this to the 2.1.1 milestone Mar 24, 2023
ravinderk
ravinderk previously approved these changes Apr 5, 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 works fine 🎉

I would like to suggest showing a PHP compatibility admin notice to the user who has the capability to manage the plugin, but it is not a blocker.

safe-svg.php Show resolved Hide resolved
safe-svg.php Show resolved Hide resolved
@dkotter dkotter merged commit 969ef2f into develop Apr 5, 2023
@dkotter dkotter deleted the fix/php-version-check branch April 5, 2023 13:57
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.

Better handling of invalid PHP versions
2 participants