You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting an inconsistent fatal error. I wish I could provide you the response back from MailChimp but I haven't been able to catch it yet, this has only happened to me a few times and I cannot reproduce consistently.
It occurs at line 517 of ListRepository.php, in "throwMailchimpError". It appears that occasionally the $errorResponse['body'] cannot be decoded into an array.
Here's the stack trace:
ErrorException: Warning: array_key_exists() expects parameter 2 to be array, null given
at Welp.MailchimpBundle.Subscriber.ListRepository.throwMailchimpError(ListRepository.php:517)
at Welp.MailchimpBundle.Subscriber.ListRepository.putSubscriberInList(ListRepository.php:85)
at Welp.MailchimpBundle.Subscriber.ListRepository.subscribe(ListRepository.php:99)
at Welp.MailchimpBundle.Event.SubscriberListener.onSubscribe(SubscriberListener.php:35)
at Symfony.Component.EventDispatcher.EventDispatcher.doDispatch(EventDispatcher.php:212)
at Symfony.Component.EventDispatcher.EventDispatcher.dispatch(EventDispatcher.php:44)
And, here's what I think an appropriate fix would be:
diff --git a/src/Subscriber/ListRepository.php b/src/Subscriber/ListRepository.php
index eff3b59..f092ac4 100644
--- a/src/Subscriber/ListRepository.php
+++ b/src/Subscriber/ListRepository.php
@@ -514,7 +514,7 @@ class ListRepository
private function throwMailchimpError(array $errorResponse)
{
$errorArray = json_decode($errorResponse['body'], true);
- if (array_key_exists('errors', $errorArray)) {
+ if (is_array($errorArray) && array_key_exists('errors', $errorArray)) {
throw new MailchimpException(
$errorArray['status'],
$errorArray['detail'],
The text was updated successfully, but these errors were encountered:
I'm afraid this fix would only make the request crash differently. In my case at least, the underlying problem is that the API wrapper fails to detect SSL validation error from cURL, see https://github.com/drewm/mailchimp-api/issues/200
I have merged #21 for now. I think it could be great to handle errors differently with try/catch in order to be more resilient. But you can also use try/catch in your app if you don't want to stop your code if there is an error.
I will close this, feel free to open another issue on the error handling subject if you want to work on it.
I'm getting an inconsistent fatal error. I wish I could provide you the response back from MailChimp but I haven't been able to catch it yet, this has only happened to me a few times and I cannot reproduce consistently.
It occurs at line 517 of ListRepository.php, in "throwMailchimpError". It appears that occasionally the $errorResponse['body'] cannot be decoded into an array.
Here's the stack trace:
And, here's what I think an appropriate fix would be:
The text was updated successfully, but these errors were encountered: