Skip to content

Conversation

@rahulsprajapati
Copy link
Contributor

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.

image

Closes #122

How to test the Change

  1. Setup a WordPress environment running PHP 7.3
  2. Install Ad-Refresh-Control plugin by downloading it with this feature branch.
  3. Verify that plugin functionality doesn't load and you see an admin error message for php version. ( refer above screenshot in Description )

Changelog Entry

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

Credits

Props @dkotter, @rahulsprajapati

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.

@rahulsprajapati rahulsprajapati requested review from a team and davidrgreen as code owners July 20, 2023 11:45
@rahulsprajapati rahulsprajapati requested review from peterwilsoncc and removed request for a team July 20, 2023 11:45
@rahulsprajapati rahulsprajapati self-assigned this Jul 20, 2023
Copy link
Contributor

@peterwilsoncc peterwilsoncc left a 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

@jeffpaul jeffpaul added this to the 1.2.0 milestone Aug 31, 2023
@jeffpaul
Copy link
Member

@peterwilsoncc alternatively, what if we bump the PHP minimum to 7.4?

@dkotter
Copy link
Collaborator

dkotter commented Oct 27, 2023

@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.

@jeffpaul
Copy link
Member

I'm also fine bumping the WP minimum to 6.2.

@jeffpaul jeffpaul requested a review from peterwilsoncc January 2, 2024 17:28
@jeffpaul jeffpaul merged commit 7e9e6aa into develop Jan 9, 2024
@jeffpaul jeffpaul deleted the fix/122-php-ver-check branch January 9, 2024 16:02
@dkotter dkotter modified the milestones: 1.2.0, 1.1.5 Aug 19, 2024
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

4 participants