If you have logintobaggan and remember me installed, there are situations where mailchimp_lists_user_update will throw errors when the user logs in. There is probably/possibly and issue with remember_me, but it only seems to bork mailchimp.

The error is as follows:

Notice: Undefined index: roles in mailchimp_lists_user_update() (line 306 of /website/docroot/sites/all/modules/mailchimp/modules/mailchimp_lists/mailchimp_lists.module).
Warning: array_diff_key() [function.array-diff-key]: Argument #2 is not an array in mailchimp_lists_user_update() (line 306 of /website/docroot/sites/all/modules/mailchimp/modules/mailchimp_lists/mailchimp_lists.module).

The issue occurs here

/**
 * Implements hook_user_update().
 */
function mailchimp_lists_user_update(&$edit, $account, $category) {
  $removed_roles = array_diff_key($edit['original']->roles, $edit['roles']);
  
  mailchimp_lists_user_sync($account, isset($edit['mail']) ? $edit['mail'] : '', $removed_roles);
}

A quick inspection of $edit reveals that $edit['roles'] is not set. So I would like to add a simple if statement check to make sure it's available.

/**
 * Implements hook_user_update().
 */
function mailchimp_lists_user_update(&$edit, $account, $category) {
  if(isset($edit['roles'])) {
    $removed_roles = array_diff_key($edit['original']->roles, $edit['roles']);

    mailchimp_lists_user_sync($account, isset($edit['mail']) ? $edit['mail'] : '', $removed_roles);
  }
}
CommentFileSizeAuthor
#1 1635430-mailchimp-user-edit-1.patch830 bytesrickmanelius
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rickmanelius’s picture

Status: Active » Needs review
FileSize
830 bytes

Patch for review:

play4quarters’s picture

Thanks so much!

I was getting the same errors when using user relationship node access, whenever I clicked on changing the default setting.

This patch fixed me right up.

Really appreciated.

rickmanelius’s picture

Status: Needs review » Reviewed & tested by the community

Hey play4quarters!

Awesome. Based on your tests, I'm going to mark this RBTC unless there are any other objections... of if the maintainer wants to test this some more.

Cheers!

jchatard’s picture

Yep that fixed the notices for me too.

Thanks!

antipex’s picture

Status: Reviewed & tested by the community » Fixed

Applied the patch in c032d80.

Status: Fixed » Closed (fixed)

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