Closed (fixed)
Project:
Mailchimp
Version:
7.x-2.5
Component:
Lists
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Jun 2012 at 18:07 UTC
Updated:
6 Aug 2012 at 21:51 UTC
Jump to comment: Most recent file
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);
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 1635430-mailchimp-user-edit-1.patch | 830 bytes | rickmanelius |
Comments
Comment #1
rickmanelius commentedPatch for review:
Comment #2
play4quarters commentedThanks 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.
Comment #3
rickmanelius commentedHey 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!
Comment #4
jchatard commentedYep that fixed the notices for me too.
Thanks!
Comment #5
antipex commentedApplied the patch in c032d80.