In mailchimp_update_local_cached_groupings the result from cache_get is not checked and leads to PHP Notices in Case there is no value in the Cache. I get this error when I try to run simple behat-tests with features assuming a user logged in. For Example if I run a Behat step like:

Given I am logged in as a user with the "administartor" role

It fails with an Exception:

Notice: Trying to get property of non-object in sites/all/modules/contrib/mailchimp/mailchimp.module line 514

This is in fact:

/**
 * Updates the locally cached interest group data.
 *
 * @array $args
 *   The args that would be sent if this was a MailChimp API call.
 * @array &$cache
 *   The current cache information for the user.
 */
function mailchimp_update_local_cached_groupings($args, &$cache) {
  $lists = cache_get('lists', 'cache_mailchimp');
  $list_data = $lists->data[$args['list_id']];
  foreach ($list_data['intgroups'] as $idx => $group_settings) {
    $interests = array();
    foreach ($group_settings['groups'] as $group) {
      if (!empty($args['merge_vars']['GROUPINGS'][$idx]['groups'][$group['name']])) {
        $interested = TRUE;
      }
      else {
        $interested = FALSE;
      }
      $interests[] = array(
        'name' => $group['name'],
        'interested' => $interested,
      );
    }
  }
}

The attached Patch adds an extra check for the cache_get-result to fix the issue.

CommentFileSizeAuthor
#2 2632568.patch2.32 KBzuernbernhard

Comments

zuernBernhard created an issue. See original summary.

zuernbernhard’s picture

StatusFileSize
new2.32 KB

Status: Needs review » Needs work

The last submitted patch, 2: 2632568.patch, failed testing.

ruscoe’s picture

Status: Needs work » Closed (won't fix)

We're going to be ending support for the 7.x-3.x branch due to the upcoming deprecation of the v2.0 MailChimp API. If you're still seeing this issue with the most recent release, please feel free to reopen for the 7.x-4.x branch.