Skip to content

Conversation

@Konamiman
Copy link
Contributor

@Konamiman Konamiman commented Jan 4, 2022

All Submissions:

Changes proposed in this Pull Request:

The minimum required PHP version will be 7.2 as of WooCommerce 6.5. This pull request adds a dismissable admin notice visible when PHP 7.0 or 7.1 is used:

image

The notice is created (if needed) when the theme is switched or a new version of WooCommerce is installed.

TODO: Add the url of the announcement post in the link included in the notice.

How to test the changes in this Pull Request:

  1. Run the following in command line to simulate a new WooCommerce version installed, this will also attempt to clear some user meta that doesn't exist yet:
wp eval 'WC_Admin_Notices::reset_admin_notices(); delete_user_meta(get_current_user_id(), "dismissed_php72_required_in_woo_65_notice");' --user=<your WP user name or id>
  1. Switch to PHP 7.2 and load any admin page, e.g. orders. You shouldn't see any notice.

  2. Switch to PHP 7.1, repeat step 1, and load the admin page again. You should see the notice.

  3. Switch to PHP 7.2, reload the admin page (DON'T repeat step 1 this time), and you should see that the notice has disappeared.

  4. Switch to PHP 7.1, repeat step 1, reload the admin page, and click the "Dismiss" button. The notice shouldn't appear anymore unless you repeat step 1.

1+2 simulates a user that was already on PHP 7.2+ at the time of upgrading to the WooCommerce release that includes this pull request, nothing will happen for these users; 3+4 simulates a user that upgrades his PHP without dismissing the notice; and 3+5 simulates a user that dismisses the notice without (or before) upgrading his PHP.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Changelog entry

Add - Admin notice warning about the upcoming minimum PHP version bump

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

The minimum required PHP version will be 7.2 as of WooCommerce 6.5.
This adds a dismissable admin notice to PHP 7.0 and 7.1 users.
@Konamiman Konamiman self-assigned this Jan 4, 2022
@jonathansadowski jonathansadowski marked this pull request as ready for review January 4, 2022 19:04
@ObliviousHarmony
Copy link
Contributor

@Konamiman it looks like this functionality already exists. Could we instead look at updating this notice and reset it for those who have already dismissed it, rather than create a new notice?

@beaulebens
Copy link
Contributor

Can we tweak the wording of this to make it explicit to the merchant/user that this change will impact them (vs it just being some informational thing to ignore)?

Maybe change the "An upgrade to at least PHP 7.4 is recommended" part to something like "Your server is currently running an older version of PHP, so this change will impact your store. Upgrading to at least PHP 7.4 is recommended".

@Konamiman
Copy link
Contributor Author

Konamiman commented Jan 7, 2022

@ObliviousHarmony I think these serve different purposes. The intent of the original notice was actually to inform about the recommended PHP version for WooCommerce, and that's why it was implemented long before we decided about the bump; but indeed the wording seems to suggest a hard requirement.

Given that we don't do a PHP version requirement bump often, I think that a "disposable" notice with whatever wording and links we need in each case is the way to go. I think that what we can do too (after Woo 6.5) is to make the original notice more clear and use it to recommend an upgrade to 7.4.

- Update the link to the announcement post
- Extend the notice text with "Your server is currently running an
  older version of PHP, so this change will impact your store".
@Konamiman
Copy link
Contributor Author

@beaulebens Text updated with your suggestion, see the updated screenshot.

@Konamiman Konamiman requested review from a team and peterfabian and removed request for a team January 10, 2022 10:13
@peterfabian
Copy link
Contributor

Related: #23975

Copy link
Contributor

@peterfabian peterfabian left a comment

Choose a reason for hiding this comment

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

Thanks, works fine, I just have one note regarding security of unrelated code.

* @deprecated 4.6.0
*/
public static function install_notice() {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
Copy link
Contributor

Choose a reason for hiding this comment

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

The third parameter is the replacement. I think

  1. we shouldn't ignore the escaping if we're passing a translated string to it, but
  2. we shouldn't actually pass anything as that's not a replacement function, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, this looks like an attempt to convey some extra information in a way that isn't really supported by the function (but no real harm done since this parameter is only used for printing error messages).

Copy link
Contributor

@ObliviousHarmony ObliviousHarmony left a comment

Choose a reason for hiding this comment

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

@Konamiman To be fair, given how strong the wording was, as well as the name of the notice (wp_php_min_requirements_notice), I do think that the original intention is not only lost but probably irrelevant. Personally, I'd still prefer we adjust the wording of the notice and reset the dismissal in a migration, but there's probably nothing wrong with a duplicate notice. I do have one performance concern with this implementation, so I've left a comment.

@Konamiman Konamiman force-pushed the add-php-72-version-bump-notice branch from 80bc066 to 0853bf4 Compare January 13, 2022 08:57
Copy link
Contributor

@peterfabian peterfabian left a comment

Choose a reason for hiding this comment

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

Looks good, works fine as far as I can see. There are some question marks around which actions to use to make things efficient, but this will go away in 3 versions, so let's take the safer route.

@peterfabian peterfabian merged commit 28f6760 into trunk Jan 13, 2022
@peterfabian peterfabian deleted the add-php-72-version-bump-notice branch January 13, 2022 09:14
@github-actions github-actions bot added this to the 6.2.0 milestone Jan 13, 2022
@github-actions
Copy link
Contributor

Hi @peterfabian, thanks for merging this pull request. Please take a look at these follow-up tasks you may need to perform:

  • Add the status: needs changelog label
  • Add the status: needs testing instructions label

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.

6 participants