TypeError on site install with --existing-config due to array_filter()

Created on 23 February 2024, 10 months ago
Updated 27 February 2024, 10 months ago

Problem/Motivation

When attempting to install a Drupal site using ddev drush site:install --existing-config, an error is encountered in the adequate_passwords module. The error occurs due to array_filter() being called with null, which happens because $form_state->getValue('roles') returns null during the installation process. This issue prevents successful site installation using the specified Drush command.

Proposed resolution

A potential resolution is to ensure that $form_state->getValue('roles') is always an array before it's passed to array_filter(). This can be achieved by modifying the line causing the error to:
$rolesValue = $form_state->getValue('roles') ?? [];
$roles = array_keys(array_filter($rolesValue));

This change ensures that array_filter() receives an empty array instead of null, avoiding the TypeError and allowing the installation process to proceed without error.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇷🇴Romania badeadrian

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