Problem/Motivation

Both of these are related but happen on an anonymous user:

Notice: Undefined index: GROUPINGS in _mailchimp_lists_subscription_has_changed() (line 343 of ./modules/mailchimp_lists/mailchimp_lists.module).
Warning: Invalid argument supplied for foreach() in _mailchimp_lists_subscription_has_changed() (line 343 of ./modules/mailchimp_lists/mailchimp_lists.module).

May be related to #2477191: _mailchimp_lists_subscription_has_changed triggers exception from EntityMetadataWrapper when a value is added to an empty field

Proposed resolution

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joelpittet’s picture

Issue summary: View changes
joelpittet’s picture

Status: Active » Needs review
FileSize
904 bytes

This patch isn't a fix(but it kinda does fix it). It's a helper to find out what is in member_info that is what groupings should be.

cubeinspire’s picture

FileSize
2.16 KB

The error happen when a webhook comes from Mailchimp without a GROUPINGS value on the array. The code doesn't take that case in consideration so I solved the issue by adding a condition if isset before the foreach.

Here is the patch.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

This is the whitespace ignored version of #3

+    if (isset($member_info['merges']['GROUPINGS'])) {
       foreach ($member_info['merges']['GROUPINGS'] as $grouping) {
         if (!isset($choices['interest_groups'][$grouping['id']])) {
           return TRUE;
@@ -362,6 +359,7 @@ function _mailchimp_lists_subscription_has_changed($instance, $field, $entity, $
         }
       }
     }
+  }
joelpittet’s picture

I think this may have been committed already in another patch because it didn't apply to 3.4

jami’s picture

Version: 7.x-3.x-dev » 7.x-3.4
Status: Reviewed & tested by the community » Fixed

Patch was applied in commit:
http://cgit.drupalcode.org/mailchimp/commit/?id=937e193

Thank you for the fix!

Status: Fixed » Closed (fixed)

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