MailchimpListsSubscription::getInterestGroups() should ALWAYS return an array

Created on 26 March 2024, 8 months ago
Updated 25 July 2024, 4 months ago

Problem/Motivation

_mailchimp_lists_subscription_has_changed() uses the output of MailchimpListsSubscription::getInterestGroups() unconditionally as input for a foreach loop. MailchimpListsSubscription::getInterestGroups() however does not always return an array.

MailchimpListsSubscription::getInterestGroups() can sometimes return NULL, and πŸ› MailchimpListsSubscription::getInterestGroups() should always return an array Fixed provides a patch for this. However, as mentioned in #3357696-4: New interest groups can be NULL β†’ , it can sometimes return FALSE, and the patch in πŸ› MailchimpListsSubscription::getInterestGroups() should always return an array Fixed does not protect against this.

Steps to reproduce

I dont know how to reproduce this from scratch. It may be related to situations where no interest groups have been defined.

Proposed resolution

Modify the definition of MailchimpListsSubscription::getInterestGroups() so that it can ONLY return an array, along the following lines:

  public function getInterestGroups() {
    $interest_groups = $this->values['interest_groups'];
    if (!is_array($interest_groups)) {
      $interest_groups = [];
    }
    return $interest_groups;
  }

Remaining tasks

Create a patch with the above fix.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Closed: duplicate

Version

2.2

Component

Lists Module

Created by

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

Comments & Activities

Production build 0.71.5 2024