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(mailchimp): prevent merge fields fetch throwing fatal error #2793

Merged

Conversation

miguelpeixe
Copy link
Member

@miguelpeixe miguelpeixe commented Dec 4, 2023

All Submissions:

Changes proposed in this Pull Request:

This fetch may fail if the audience does not exist in Mailchimp (Resource not found). This change prevents this error from throwing a fatal error and breaking the donation flow.

How to test the changes in this Pull Request:

  1. Make sure you have RAS enabled and Newspack Newsletters is connected Mailchimp
  2. Confirm you have define( 'NEWSPACK_LOG_LEVEL', 2 );
  3. While on the release branch confirm the error by adding $audience_id = 'foo'; to line 53 of includes/data-events/connectors/class-mailchimp.php
  4. Go through the donation flow and confirm the donation order goes through but you get an unhandled error in the UI
  5. Check out this branch, apply the same $audience_id = 'foo'; line, and got through the donation flow again
  6. Confirm the donation succeeds and the logs shows: [28441][NEWSPACK][Newspack\Data_Events\Connectors\Mailchimp::get_merge_fields]: Error getting merge fields: Resource Not Found

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?

@miguelpeixe miguelpeixe self-assigned this Dec 4, 2023
@miguelpeixe miguelpeixe requested a review from a team as a code owner December 4, 2023 21:42
Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

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

Works well! Here's a fix for the same code in Newsletters: Automattic/newspack-newsletters#1376

It's less urgent because it doesn't result in a reader-facing error (although the reader doesn't get subscribed to the list as intended).

@github-actions github-actions bot added the [Status] Approved The pull request has been reviewed and is ready to merge label Dec 5, 2023
@miguelpeixe miguelpeixe merged commit 9b9d3ab into release Dec 5, 2023
1 check passed
@miguelpeixe miguelpeixe deleted the hotfix/mailchimp-connector-check-merge-field-response branch December 5, 2023 12:01
matticbot pushed a commit that referenced this pull request Dec 5, 2023
## [2.11.6](v2.11.5...v2.11.6) (2023-12-05)

### Bug Fixes

* **mailchimp:** prevent merge fields fetch throwing fatal error ([#2793](#2793)) ([9b9d3ab](9b9d3ab))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 2.11.6 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Dec 5, 2023
# [2.12.0-alpha.4](v2.12.0-alpha.3...v2.12.0-alpha.4) (2023-12-05)

### Bug Fixes

* **mailchimp:** prevent merge fields fetch throwing fatal error ([#2793](#2793)) ([9b9d3ab](9b9d3ab))
@matticbot
Copy link
Contributor

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

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
Labels
released on @alpha released [Status] Approved The pull request has been reviewed and is ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants