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.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 3096797-8-4-interdiff.txt | 1.17 KB | mbovan |
| #8 | 3096797-8.patch | 638 bytes | mbovan |
| #4 | array_filter_on_mergevars-3096797-4.patch | 831 bytes | ivan berezhnov |
| #2 | array_filter_on_mergevars-3096797-2.patch | 800 bytes | kaduk |
| Screenshot 2019-11-26 at 10.58.38.png | 423.89 KB | kaduk |
Comments
Comment #2
kaduk commentedI also created a quick patch to fix this.
Comment #3
ivan berezhnov commentedI have same issue.
Comment #4
ivan berezhnov commentedMy 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.
Comment #5
ivan berezhnov commentedComment #6
sokru commentedHad 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$mergevarsis set.Another approach is to do something like:
Comment #7
mbovan commentedComment #8
mbovan commentedSince
mailchimp_lists_mergevars()andwebform_mailchimp_lists_mergevars()expect$mergevarsto be an array I would prefer solution from #6.Comment #10
mbovan commentedFixed.