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: memberships sync #63

Merged
merged 2 commits into from
Feb 21, 2024
Merged

fix: memberships sync #63

merged 2 commits into from
Feb 21, 2024

Conversation

adekbadek
Copy link
Member

All Submissions:

Changes proposed in this Pull Request:

Fixes the memberships sync (#40). If a membership is created, it means that it already exists on a remote site (it was synced to the site running the sync).

How to test the changes in this Pull Request:

This can't actually be tested until memberships backfill (#62) is in place.

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?

Copy link
Contributor

@leogermani leogermani left a comment

Choose a reason for hiding this comment

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

The goal is to prevent the metadata from being added when running the action a second time?

I think we need to add some safeguards there, because $user_membership can be a WP_Error object

Maybe add a $is_creating variable and only update the meta then?

@adekbadek
Copy link
Member Author

The goal is to prevent the metadata from being added when running the action a second time?

Not exactly, the goal is to only add the metadata if the membership is a "cloned" one.

I think we need to add some safeguards there, because $user_membership can be a WP_Error object

The return type is \WC_Memberships_User_Membership|null, so I've added explicit null handling in 5b093a0.

Also, updated the safeguard against inactive plugin – as we've learned recently (Automattic/newspack-newsletters#1437 (comment)) it's best to directly check for the functions used.

@adekbadek adekbadek merged commit 0a54f1d into trunk Feb 21, 2024
3 checks passed
@adekbadek adekbadek deleted the fix/memberships-sync branch February 21, 2024 18:50
matticbot pushed a commit that referenced this pull request Feb 23, 2024
# [1.3.0-alpha.1](v1.2.0...v1.3.0-alpha.1) (2024-02-23)

### Bug Fixes

* memberships sync ([#63](#63)) ([0a54f1d](0a54f1d))

### Features

* add hub bookmarks to nodes ([#56](#56)) ([54700a0](54700a0))
* add option to manually sync users  ([#53](#53)) ([3ec1b19](3ec1b19))
* display membership plans from the network ([#59](#59)) ([6fa01fd](6fa01fd))
* enhance network subscriptions and orders search ([#55](#55)) ([bcb0615](bcb0615))
* Node connection using a link ([#58](#58)) ([721f8b2](721f8b2))
* **wp-cli:** add command to backfill events ([#51](#51)) ([13d2498](13d2498))
* **wp-cli:** add process pending webhook requests command ([#67](#67)) ([7dbd8dc](7dbd8dc))
* **wp-cli:** sync all events from the Hub ([#65](#65)) ([dc595ca](dc595ca))
@matticbot
Copy link
Contributor

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

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Feb 28, 2024
# [1.3.0](v1.2.0...v1.3.0) (2024-02-28)

### Bug Fixes

* backfill duplicate handling; woo links in wp-admin-bar ([#71](#71), [#72](#72)) ([bbce13b](bbce13b))
* cli commands ([#73](#73)) ([ff563ac](ff563ac))
* memberships sync ([#63](#63)) ([0a54f1d](0a54f1d))
* missing woocommerce-memberships handling ([76dbdf7](76dbdf7))

### Features

* add hub bookmarks to nodes ([#56](#56)) ([54700a0](54700a0))
* add option to manually sync users  ([#53](#53)) ([3ec1b19](3ec1b19))
* display membership plans from the network ([#59](#59)) ([6fa01fd](6fa01fd))
* enhance network subscriptions and orders search ([#55](#55)) ([bcb0615](bcb0615))
* Node connection using a link ([#58](#58)) ([721f8b2](721f8b2))
* **wp-cli:** add command to backfill events ([#51](#51)) ([13d2498](13d2498))
* **wp-cli:** add process pending webhook requests command ([#67](#67)) ([7dbd8dc](7dbd8dc))
* **wp-cli:** sync all events from the Hub ([#65](#65)) ([dc595ca](dc595ca))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.3.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.

3 participants