Note: this might be similar to another issue with 7.x here - https://www.drupal.org/node/2751831#comment-11466387 - but I'm getting it with 8.x-dev.

I'm using Mailchimp 8.x-dev, Drupal 8.1.8.

On localhost (homestead setup with php7/nginx) mailchimp lists work great.

However, on a fresh DigitalOcean install (Ubuntu16,PHP7.0,Nginx, SSL) whenever i run a cache rebuild, i loose all the lists in mailchimp - and the signup forms stop working.

I get the following notice when going back to mailchimp and clicking to refresh the lists.

Notice: Trying to get property of non-object in mailchimp_get_lists()

I'm having a hard time finding rhyme or reason for it. When it stops working, it doesn't work immediately after drush cache-rebuild, cron run, etc. Then in an hour or two, or sometimes the next day, it'll just start working.

Comments

chuckienorton created an issue. See original summary.

ruscoe’s picture

Sounds like the lists aren't being pulled from MailChimp and cached when they should be.

Until we have a fix for this, could you try loading /admin/config/services/mailchimp/lists immediately after a cache clear? That should force all your lists to be retrieved again.

chuckienorton’s picture

Thanks @Ruscoe.

I replied slowly here because

First - I tried your suggestion and cleared the cache specifically from that page in fact. No luck.

Second - i decided i would make sure all the other modules & drupal were updated just in case that had something to do with it. Now i'm on Drupal 8.2.2 and the issue persists. It still works great on local vagrant box, and doesn't work on live site. I even checked mailchimp's api keys page & it actually shows a call to /lists and successful response.

Third -

I also considered (from googling around) this issue where mailchimp isn't happy with my servers ssl. However i run the following from ssh:

echo GET | openssl s_client -CApath /etc/ssl/certs/ -connect us3.api.mailchimp.com:443 2>&1

... I get a successful response.

Fourth -

I considered that this could have something to do with my cache bins. So i switched my settings.php & settings.yaml files to look similar to local server - with

$settings['cache']['bins']['render'] = 'cache.backend.null'; 

But that still didn't change the fact that mailchimp lists don't refresh.

Definitely has something to do with caching. But I'm at a loss for why or how to fix.

I woke up this morning and they were magically working again. Then i hit ./drush cr and they stopped. :(

Thanks again for help!

chuckienorton’s picture

PS - follow up on full error notice from error logs:

Notice: Trying to get property of non-object in mailchimp_get_lists() (line 119 of /path/to/site.com/web/modules/contrib/mailchimp/mailchimp.module) #0 /path/to/site.com/web/core/includes/bootstrap.inc(548): _drupal_error_handler_real(8, 'Trying to get p...', '/path/to/site...', 119, Array) #1 /path/to/site.com/web/modules/contrib/mailchimp/mailchimp.module(119): _drupal_error_handler(8, 'Trying to get p...', '/path/to/site...', 119, Array) #2 /path/to/site.com/web/modules/contrib/mailchimp/modules/mailchimp_lists/src/Form/MailchimpListsClearCacheForm.php(58): mailchimp_get_lists(Array, true) #3 [internal function]: Drupal\mailchimp_lists\Form\MailchimpListsClearCacheForm->submitForm(Array, Object(Drupal\Core\Form\FormState)) #4 /path/to/site.com/web/core/lib/Drupal/Core/Form/FormSubmitter.php(111): call_user_func_array(Array, Array) #5 /path/to/site.com/web/core/lib/Drupal/Core/Form/FormSubmitter.php(51): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object(Drupal\Core\Form\FormState)) #6 /path/to/site.com/web/core/lib/Drupal/Core/Form/FormBuilder.php(585): Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object(Drupal\Core\Form\FormState)) #7 /path/to/site.com/web/core/lib/Drupal/Core/Form/FormBuilder.php(314): Drupal\Core\Form\FormBuilder->processForm('mailchimp_lists...', Array, Object(Drupal\Core\Form\FormState)) #8 /path/to/site.com/web/core/lib/Drupal/Core/Controller/FormController.php(74): Drupal\Core\Form\FormBuilder->buildForm('mailchimp_lists...', Object(Drupal\Core\Form\FormState)) #9 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #10 /path/to/site.com/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #11 /path/to/site.com/web/core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #12 /path/to/site.com/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #13 /path/to/site.com/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #14 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #15 /path/to/site.com/vendor/symfony/http-kernel/HttpKernel.php(144): call_user_func_array(Object(Closure), Array) #16 /path/to/site.com/vendor/symfony/http-kernel/HttpKernel.php(64): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #17 /path/to/site.com/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #18 /path/to/site.com/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #19 /path/to/site.com/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #20 /path/to/site.com/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #21 /path/to/site.com/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #22 /path/to/site.com/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /path/to/site.com/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 /path/to/site.com/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 /path/to/site.com/web/core/lib/Drupal/Core/DrupalKernel.php(652): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #26 /path/to/site.com/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #27 {main}.

daou’s picture

Did you find a solution for this?

abarrio’s picture

Hi! I Had this error in a project. I was looking for a solution for the problem and I found one, I don't know if it is the best solution but it works.
The problem is that api response comes without body from mailchimp when http request have version to 1.1 setted (This is the default version that set GuzzleHttp).

I add an extra param in /mailchimp/lib/mailchimp-api-php/src/Mailchimp.php on request method before client->request call.

//Set version of http to 1.0 in order to avoid body formatter error
$options['version'] = '1.0';
katski’s picture

thanks @abarrio that worked for me, having exact same issue.

jafacakes2011’s picture

I noticed that the member counts on my lists were not updating, making the change @abarrio suggested fixed it for me.

Can we look at getting a patch for this to be applied?

abarrio’s picture

Component: Lists » General

Hi,

after years of this issue still open I have been checking the code of module and I realized that now the library is using composer to be downloaded so maybe we can include a patch on module composer.json file.

Makes sense?

kescoto-thinkshout’s picture

Assigned: Unassigned » kescoto-thinkshout
Status: Active » Postponed (maintainer needs more info)

This issue came up on an older version of the module and we haven't been able to recreate. Postponing until we confirm this is still an issue. @chuckienorton, can you let us know? And @abarrio, can you provide additional info on where to put the patch code if it has changed since 2017?