When adding or editing a user account I get this error:

warning: Invalid argument supplied for foreach() in /XXXXXX/public/sites/all/modules/mailchimp/mailchimp.module on line 914.

Comments

jerry’s picture

Yep, I just noticed this, too.

levelos’s picture

I can't recreate. Can you provide more specific details? Thanks.

jerry’s picture

Wish I could; I've just seen it from time to time in the log during a cron run, apparently during a mailing list sync.

Clint Eagar’s picture

Here are some log entries:

Type	mailchimp
Date	Monday, February 14, 2011 - 11:47
User	Administrator
Location	http://www.xxxxx.com/user/8/edit?destination=admin%2Fuser%2Fuser
Referrer	http://www.xxxxx.com/user/8/edit?destination=admin%2Fuser%2Fuser
Message	rob@xxx.com has failed to subscribed to Test List.
Severity	warning
Hostname	76.8.223.68
Operations	

It looks like the module is referencing old lists. I was using a test Mailchimp account in development and then switched to a different in production.

plamondonl’s picture

I have the same error and I me too I upgraded from an older version of the module (Mailchimp 2.2 to 2.4). In 2.2, variable_get('mailchimp_lists', array()) returns a serialized array and it is unserialized before being passed to the foreach loop in _mailchimp_get_available_lists(). In 2.4, I suppose variable 'mailchimp_lists' is no longer serialized because there is no unserialize() call before the foreach loop. In my case, the content of 'mailchimp_lists' is still serialized so that's why a warning is produced when using 2.4. I guess there is nothing to fix. I'll just uninstall and reinstall the module properly.

Gabriel R.’s picture

Same problem here. After an upgrade, the mailing links are no longer listes in the module config page. The subscription option is however still present in the user account. Enabling the ghost newsletter returns the error "warning: Invalid argument supplied for foreach() in /.../sites/all/modules/mailchimp/mailchimp.module on line 914.

My problem is that the newsletters are gone from config.

kenwen’s picture

not sure if this is related but i get this error on user sign up

Duplicate entry '11' for key 1 query: INSERT INTO mailchimp_user (uid, status) VALUES (11, 'pending') in /xxx/mailchimp.module on line 113

levelos’s picture

Status: Active » Closed (cannot reproduce)

Update mailchimp_update_6203() should take care of the migration from serialized to unserialized storage. If you have any issue, try just re-saving your settings at admin/config/mailchimp.

javier1968’s picture

I also have the same issue even when I installed the latest version from scratch with no update required.

http://www.tyndall.ac.uk/mailchimp/subscribe

ahmu83’s picture

Component: Code » General

The error caused is due to passing a non-array variable to foreach on line # 927

foreach ($mergevars as $mergevar) {

I have wrapped that foreach loop in an array check

if(is_array($mergevars)){
  foreach ($mergevars as $mergevar) {
    if (!empty($list->mergevars[$mergevar['tag']]) && $key = $list->mergevars[$mergevar['tag']]) {
      $uservars[$mergevar['tag']] = $account[$key];
    }
  }
  return $uservars;
}

this fixed the problem but not sure how it will affect the functionality.