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

fix: handle inactive woocommerce #1437

Merged
merged 2 commits into from
Mar 7, 2024
Merged

Conversation

adekbadek
Copy link
Member

All Submissions:

Changes proposed in this Pull Request:

Add a check for WC function existence.

How to test the changes in this Pull Request:

Should be self-explanatory, but if testing is needed – I've encountered this after deactivating woocommerce and editing a post. PHP Errors are logged in this situation on trunk.

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 ran tests with your changes locally?

@@ -79,6 +79,9 @@ public static function filter_lists( $lists ) {
if ( ! is_array( $lists ) || empty( $lists ) ) {
return $lists;
}
if ( ! function_exists( 'wc_memberships_is_post_content_restricted' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm so apparently this happens if woo memberships is active but woocommerce is not.

I think it's best to fix the check on the init method, that checks class_exists( 'WC_Memberships_Loader' ). If Woo and/or Woo memberships is not active, the hooks should not even be initalized

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, added in acacf58

@laurelfulford laurelfulford merged commit b369d54 into trunk Mar 7, 2024
7 checks passed
@laurelfulford laurelfulford deleted the fix/handle-no-woocommerce branch March 7, 2024 17:39
matticbot pushed a commit that referenced this pull request Mar 7, 2024
# [2.12.0-alpha.1](v2.11.1...v2.12.0-alpha.1) (2024-03-07)

### Bug Fixes

* handle inactive woocommerce ([#1437](#1437)) ([b369d54](b369d54))
* **mc:** log add_user_to_lists errors ([#1444](#1444)) ([c53b02a](c53b02a))

### Features

* update translation strings  ([#1435](#1435)) ([822c7e1](822c7e1))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 2.12.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Mar 25, 2024
# [2.12.0](v2.11.2...v2.12.0) (2024-03-25)

### Bug Fixes

* handle inactive woocommerce ([#1437](#1437)) ([b369d54](b369d54))
* **mc:** log add_user_to_lists errors ([#1444](#1444)) ([c53b02a](c53b02a))

### Features

* update translation strings  ([#1435](#1435)) ([822c7e1](822c7e1))

### Reverts

* chore(release): 2.12.0-alpha.1 to avoid conflicts [skip ci] ([4ba5000](4ba5000))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 2.12.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants