I have created a simple webform with an email field and a GDPR checkbox (which we created at the company I work).
I then have added a mailchimp handler to the form and selected the mailling list you want to subscribe to.
When you then want to submit the form you get the following error.

array_filter() expects parameter 1 to be array, null given in Drupal\webform_mailchimp\Plugin\WebformHandler\WebformMailChimpHandler->postSave()

The complete stacktrace can be seen in the screenshot.

Comments

kaduk created an issue. See original summary.

kaduk’s picture

StatusFileSize
new800 bytes

I also created a quick patch to fix this.

ivan berezhnov’s picture

I have same issue.

ivan berezhnov’s picture

StatusFileSize
new831 bytes

My fix in the file.

In the mailchimp_subscribe function by default third argument is NULL.

Here problem because an editor or an admin didn't add Mailchimp vars in settings.

ivan berezhnov’s picture

Status: Active » Needs review
sokru’s picture

Status: Needs review » Reviewed & tested by the community

Had the same issue because I have no mergevars in use. Applied the patch from #2. Patch #4 is basically the same but it doesn't assign $mergevars = array() if no $mergevars is set.

Another approach is to do something like:

286     $mergevars = Yaml::decode($configuration['mergevars']) ?? [];
mbovan’s picture

mbovan’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new638 bytes
new1.17 KB

Since mailchimp_lists_mergevars() and webform_mailchimp_lists_mergevars() expect $mergevars to be an array I would prefer solution from #6.

  • mbovan committed 3be6228 on 8.x-5.x
    Issue #3096797 by kaduk, mbovan, Ivan Berezhnov, sokru: array_filter()...
mbovan’s picture

Status: Needs review » Fixed

Fixed.

Status: Fixed » Closed (fixed)

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