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

Adds compat checker for versioning and compatibility #2640

Merged
merged 9 commits into from
May 14, 2024

Conversation

ibndawood
Copy link
Contributor

@ibndawood ibndawood commented Oct 6, 2023

Changes proposed in this Pull Request:

Closes #2639.

This PR uses the compat-checker library from the WooCommerce Grow repo to run compatibility and versioning checks during the plugin initialisation.

Checks:

  • Does your code follow the WordPress coding standards?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Screenshots:

Screenshots are for reference. WooCommerce Brands will be replaced by Facebook for WooCommerce.

WooCommerce not installed

image

WooCommerce not activated

image

WooCommerce not compatible

image

WooCommerce not tested

image

Detailed test instructions:

Pre-requisites

The PR requires deleting transients. A plugin like Transients Manager is recommended to delete the transients between tests.

WooCommerce activation tests

With the above code snippets in place, run the following tests. The instructions are for Facebook for WooCommerce but can be used for other WooGrow Extensions.

  1. Install and activate Facebook for WooCommerce without installing WooCommerce.
  2. Deactivate WooCommerce.
  3. Verify the notice Facebook for WooCommerce requires WooCommerce to be installed and activated. Please install WooCommerce. is displayed.
  4. Install WooCommerce without activating.
  5. Verify the notice Facebook for WooCommerce requires WooCommerce to be activated. Please activate WooCommerce. is displayed.

WooCommerce versioning tests

⚠️ Important note: You will need to erase the transient _transient_wc_grow_compat_checker_[EXTENSION].php[VERSION after each change!!

  1. Install and activate WooCommerce.
  2. Install and activate Facebook for WooCommerce.
  3. Modify the WC requires at least header field and set it to a version higher than the active WooCommerce version. Let's say the WC requires at least is set to 8.2 and the active WooCommerce version is 8.0.2.
  4. Verify the notice Facebook for WooCommerce requires WooCommerce version 8.2 or higher. Please update WooCommerce to the latest version, or download the minimum required version is displayed.
  5. Modify the WC tested up to and set it to a lower version than the active WooCommerce version. Let's say the WC tested up to is set to 7.8, the active WooCommerce version is 8.0.2 and Facebook for WooCommerce version is 3.0.34.
  6. Verify the warning notice Facebook for WooCommerce - 3.0.34 is untested with WooCommerce 8.0.2 is displayed.

L2 support recommendation notice

  1. Download the latest minus three WooCommerce version and activate it. Let's say 7.6.
  2. Verify the warning notice Heads up! Facebook for WooCommerce will soon discontinue support for WooCommerce 7.6. Please update WooCommerce to take advantage of the latest updates and features.

WordPress versioning tests

⚠️ Important note: You will need to erase the transient _transient_wc_grow_compat_checker_[EXTENSION].php[VERSION after each change!!

  1. Modify the Tested up to and set it to a lower version than the current WordPress version. Let's say the Tested up to is set to 6.2, the active WordPress version is 6.3, and the Facebook for WooCommerce version is 3.0.34.
  2. Verify the warning notice Facebook for WooCommerce - 3.0.34 is untested with WordPress 6.3 is displayed.

Additional Details

To delete a transient using Transients Manager, navigate to Tools > Transients, search for wc_grow and delete the transient.

Changelog entry

Add - Versioning and compatibility checks to implement support policy.

@ibndawood ibndawood self-assigned this Oct 6, 2023
@github-actions github-actions bot added changelog: add A new feature, function, or functionality was added. type: enhancement The issue is a request for an enhancement. labels Oct 6, 2023
@@ -127,7 +129,7 @@ public function __wakeup() {
*/
public function init_plugin() {

if ( ! $this->plugins_compatible() ) {
if ( ! Checker::instance()->is_compatible( __FILE__, self::PLUGIN_VERSION ) || ! $this->plugins_compatible() ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't Checker::instance()->is_compatible( FILE, self::PLUGIN_VERSION ) move inside plugins_compatible ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good catch, @rawdreeg. My approach was not to disturb existing checks. However, in this case, we can remove the plugins_compatible method and replace it with Checker::instance()->is_compatible( FILE, self::PLUGIN_VERSION ) alone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've implemented the above suggestion in this commit: 8eefaf3

@ibndawood ibndawood marked this pull request as ready for review October 12, 2023 06:07
@ibndawood
Copy link
Contributor Author

Thank you, @rawdreeg, for taking the time to review the PR. I've pushed a couple of commits addressing your comments. Please let me know your thoughts.

@@ -127,7 +129,7 @@ public function __wakeup() {
*/
public function init_plugin() {

if ( ! $this->plugins_compatible() ) {
if ( ! Checker::instance()->is_compatible( __FILE__, self::PLUGIN_VERSION ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably means we can remove plugins_compatible as this is a private method and it's no longer used :-)

Copy link
Contributor

@rawdreeg rawdreeg 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, Thanks @ibndawood . I added a suggestion to remove the plugins_compatible method. but that's left up to you :-)

@ibndawood ibndawood merged commit ecf18d6 into develop May 14, 2024
4 checks passed
@ibndawood ibndawood deleted the add/2639-compat-checker branch May 14, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: add A new feature, function, or functionality was added. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add WooCommerce compatibility and versioning
2 participants