Mailchimp are currently several hours into a geographic outage. An opportunity to make the module more robust!

* In mailchimp_get_api_object() the client timeout was hardcoded to 60 seconds, despite being configurable in the bundled Mailchimp client library.
* The bundled client library has deprecated $timeout parameter to new client instantiation, replacing it with $http_options which supports $http_options['timeout'].
* mailchimp_campaign_list_templates() does not catch exceptions as it is done through much of the rest of the module.
* mailchimp_campaign_entity_storage_load() does not check if $mc_campaigns[$mc_campaign_id] exists before using it.
* document the timeout setting

Comments

xurizaemon created an issue. See original summary.

xurizaemon’s picture

xurizaemon’s picture

Issue summary: View changes

PS. If you'd like any of this split into separate issues or patches, just say so - happy to oblige. With 280 open issues, I figured it would be simpler to submit it as a single bite :)

xurizaemon’s picture

On review, I'm not sure that timeout setting is a hidden setting - pretty sure I saw it referenced somewhere in config, but maybe that was MC API config not Mailchimp module config. This PR treats it as one, in which case we perhaps should add it to config/install/mailchimp.settings.yml?

If not existing config, I propose we add it. Hardcoded 60 second timeout was a sitekiller. MC API seems to default to 10s.

thursday_bw’s picture

xurimon.. :) You have copied your commit information from your console in this patch along with your diff, so.. it's not going to apply.

I think it would be worth breaking the timeout issues and the mailchimp_campaign_entity_storage_load() into separate issues.

xurizaemon’s picture

Thanks.

That patch seems to apply OK from this project's composer.json? I think it's fine, that's the patch format generated when I git show to generate a patch. The maintainer can optionally use that or apply their own commit message. See this SE question for more.

Agree on mailchimp_campaign_entity_storage_load.

zerolab’s picture

It is worth replacing the use of drupal_set_message() which got deprecated in Drupal 8.5.0 and replace with \Drupal\Core\Messenger\MessengerInterface::addMessage()

xurizaemon’s picture

@zerolab, while it's a trivial change (patch), I feel like that should be a separate issue, since:

  • replacing the one drupal_add_message() in this patch would leave several other usages in the same file unmatched
  • replacing the many usages in this file would leave mailchimp_campaign.module unmatched with the rest of the module
  • replacing all the usages in this module would not be in scope of this change
  • I'm unsure of the support policy of this module regarding Drupal >= 8 < 8.5, but that change would break sites below 8.5 wouldn't it? (I guess they can just use an older Mailchimp module?)

Since this is all procedural code here, the patch linked uses the static \Drupal::messenger()->addMessage('foo'); syntax.

xurizaemon’s picture

I've opened separate issue #3019881: Update relevant services to use dependency injection for @zerolab's proposed change in comment 7.

gold’s picture

A couple of things broke this patch and some other issues made other bits redundant.

Rerolled the patch. Still needs review.

thursday_bw’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, reviewed and tested.

I do say I don't like the number of hooks being used. Worth some investigation as to whether some can be replaced by events. But that's
a separate issue altogether.. would be great to get this patch through, it's clean, simple, makes sense and works.

Cleaning this issue of the list makes space for energy to be spent on more important features.

brendanthinkshout’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new3.44 KB

While the change in #3081006 did update the HTTP options structure in mailchimp.module, it didn't incorporate the ability to retrieve a timeout length from config, which is part of the motivation for this issue. Rerolling to incorporate that line.

gold’s picture

StatusFileSize
new3.27 KB
new548 bytes

Good catch. :) However, Config::get() doesn't take a default value like that.

Checking how to do this correctly it appears ?: is the right approach. There's a good summary of this on issue #2090751, which was looking at adding this functionality, but ultimately closed as "Closed (won't fix)."

brendanthinkshout’s picture

Assigned: Unassigned » brendanthinkshout

I suspect that is the right approach, but the above patch no longer applies to the most recent commit on 1.x. Will reroll.

gcb’s picture

Assigned: brendanthinkshout » wxactly
wxactly’s picture

StatusFileSize
new1.57 KB

A configurable timeout value is being set with the fix for https://www.drupal.org/project/mailchimp/issues/2768455

I re-rolled this patch so that it only has the additional robustness for the campaign template list call.

  • wxactly committed 7703e63 on issue-2998712
    Issue #2998712 by Gold, xurizaemon, brendanthinkshout, wxactly: Improve...
wxactly’s picture

  • gcb committed ac0cc3e on 8.x-1.x authored by wxactly
    Issue #2998712 by Gold, xurizaemon, brendanthinkshout, wxactly: Improve...
gcb’s picture

Version: 8.x-1.x-dev » 2.x-dev
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.