Update mailchimp_update_member_process for $tags

Created on 22 February 2023, almost 2 years ago
Updated 2 April 2024, 9 months ago

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;
}

πŸ› Bug report
Status

Fixed

Version

2.0

Component

General

Created by

πŸ‡ΊπŸ‡ΈUnited States derekw

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024