The mailchimp_update_member_process function in mailchimp.module does not include the $tags variable in its function declaration, neither does it do anything with $tags like the mailchimp_subscribe_process function does.

This breaks cron when processing mailchimp updates via cron, because the new $tags variable is set in the cron queue item args array but is missing from the mailchimp_update_member_process function declaration. You'll see in the dblog: Error: Unknown named parameter $tags in mailchimp_cron() (line 1423 of /code/web/modules/contrib/mailchimp/mailchimp.module).

Here's what I think the function should be, to match mailchimp_subscribe_process, adding $tags=NULL in the function declaration, and tag handling (copied from mailchimp_subscribe_process) at the end of the function.

function mailchimp_update_member_process($list_id, $email, $merge_vars, $interests, $format, $double_optin = FALSE, $gdpr_consent = FALSE, $tags = NULL) {

.....

  if ($double_optin) {
    $msg = $config->get('optin_check_email_msg');
    if ($msg) {
      \Drupal::messenger()->addStatus($msg, FALSE);
    }
  }


  // Add or update member tags
  if ($tags) {
    $tags = explode(',', (string) $tags);
    $tags = array_map('trim', $tags);

    try {
      $mcapi->addTagsMember($list_id, $tags, $email);
    }

    catch (ClientException $e) {
      \Drupal::logger('mailchimp')->error('An error occurred while adding tags for this email({email}) to Mailchimp: {message}', [
        'message' => $e->getMessage(),
        'email' => $email,
      ]);
    }
  }
  return $result;
}

Issue fork mailchimp-3343846

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

derekw created an issue. See original summary.

derekw’s picture

Version: 2.2.0-rc1 » 2.x-dev
Issue summary: View changes
derekw’s picture

Issue summary: View changes
derekw’s picture

Issue summary: View changes

derekw’s picture

Issue summary: View changes

xenophyle made their first commit to this issue’s fork.

xenophyle’s picture

Status: Active » Needs review

xenophyle’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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