-
Notifications
You must be signed in to change notification settings - Fork 22
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: let the exceptions be thrown #1698
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #1698 +/- ##
============================================
+ Coverage 20.35% 20.46% +0.10%
+ Complexity 2670 2660 -10
============================================
Files 48 48
Lines 10640 10614 -26
============================================
+ Hits 2166 2172 +6
+ Misses 8474 8442 -32 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, on this branch after changing the Mailchimp API key to something invalid and refreshing the cache, I don't see any errors in the Settings page after the SURFACE_ERRORS_AFTER
amount of time has passed. I also see some warnings in the debug log that seem related:
[11-Nov-2024 23:14:17 UTC] PHP Warning: Undefined array key "lists" in /newspack-repos/newspack-newsletters/includes/service-providers/mailchimp/class-newspack-newsletters-mailchimp-cached-data.php on line 542
[11-Nov-2024 23:14:17 UTC] PHP Warning: Undefined array key "lists" in /newspack-repos/newspack-newsletters/includes/service-providers/mailchimp/class-newspack-newsletters-mailchimp-cached-data.php on line 546
[11-Nov-2024 23:14:17 UTC] PHP Warning: foreach() argument must be of type array|object, null given in /newspack-repos/newspack-newsletters/includes/service-providers/mailchimp/class-newspack-newsletters-mailchimp.php on line 629
The pattern we use in Newsletters is not something we use in other plugins and we keep forgetting about it.
The pattern is that instead of returning errors, the methods will throw exceptions that we need to catch. This is the basis of the
validate
method so I followed the same thing for the whole Mailchimp Cache class.
I wonder if we should retain this pattern since it keeps breaking our brains? Could we refactor the validate
method to use WP_Error
s instead of exceptions that we need to catch and handle manually? Maybe outside the scope of this PR, but I feel this pattern has anecdotally bitten us more than helped us.
@dkoo I can't reproduce what you described. This branch was outdated, so it might have contributed. Here is what I see:
Also, I noticed that we were never clearing the |
ah, and about this. You're probably right. We should use a pattern we use everywhere else... but I personally don't want to engage in this refactor right now :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working for me after the refresh. Thanks, @leogermani!
Hey @leogermani, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |
# [3.6.0-alpha.1](v3.5.0...v3.6.0-alpha.1) (2024-11-29) ### Bug Fixes * let the exceptions be thrown ([#1698](#1698)) ([85746b8](85746b8)) ### Features * **ras-acc:** add reader account creation and login improvements ([#1716](#1716)) ([4640cae](4640cae)) * rate limit requests for CC ([#1714](#1714)) ([ad092ca](ad092ca))
🎉 This PR is included in version 3.6.0-alpha.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
All Submissions:
Changes proposed in this Pull Request:
See #1690 (review)
This PR reverts #1636
The pattern we use in Newsletters is not something we use in other plugins and we keep forgetting about it.
The pattern is that instead of returning errors, the methods will throw exceptions that we need to catch. This is the basis of the
validate
method so I followed the same thing for the whole Mailchimp Cache class.In #1636, we are supressing this errors, and the result is that they are not being surfaced when they should.
The thing that we were solving in #1636 was not an issue, it was expected behavior, you can see by the methods doc blocks that they are expected to throw.
How to test the changes in this Pull Request:
Smoke test
Other information: