Problem/Motivation

Seeing this error happen in the logs semi-frequently:

Uncaught PHP Exception TypeError: "my_module_mailchimp_lists_interest_groups_alter(): Argument #1 ($interests) must be of type array, false given, called in /var/www/prod/csp/site/core/lib/Drupal/Core/Extension/ModuleHandler.php on line 474"

Steps to reproduce

Unsure.

Proposed resolution

This is fairly easy to prevent by doing proper type checking.

This line in mailchimp_lists_process_subscribe_form_choices() uses a null coalescing operator, but that won't do anything if the value is FALSE rather than NULL. I suggest using is_array() instead.

$interests = $choices['interest_groups'] ?? [];

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork mailchimp-3616713

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

rob230 created an issue. See original summary.

  • xenophyle committed edce50d0 on 3.x authored by rob230
    fix: #3616713 Boolean used as array - interests can be FALSE
    
    By: rob230
    

  • xenophyle committed 34df4e9f on 2.x authored by rob230
    fix: #3616713 Boolean used as array - interests can be FALSE
    
    By: rob230
    

  • xenophyle committed 9264deec on 3.2.x authored by rob230
    fix: #3616713 Boolean used as array - interests can be FALSE
    
    By: rob230
    
xenophyle’s picture

Status: Active » Fixed

Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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