Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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 CreditAttribution: rickmanelius commentedPatch for review:
Comment #2
play4quarters CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: jchatard commentedYep that fixed the notices for me too.
Thanks!
Comment #5
antipex CreditAttribution: antipex commentedApplied the patch in c032d80.