TypeError: array_keys(): Argument #1 ($array) must be of type array, string given in array_keys() (line 366 of list.module

Created on 4 December 2023, 12 months ago
Updated 19 June 2024, 5 months ago

Problem/Motivation

Previous exports of fields with allowed_values_function exported with Features had set the value of the field settings like this:

array (
  'allowed_values' => '',
  'allowed_values_function' => '_MY_CUSTOM_ALLOWED_VALUES',
  'allowed_values_php' => '',
  'profile2_private' => false,
)

And note the allowed_values is a string which leads to this fatal error in PHP 8.1 inside list_field_update_forbid()

TypeError: array_keys(): Argument #1 ($array) must be of type array, string
given in array_keys() (line 366 of
modules/field/modules/list/list.module).

Steps to reproduce

Set the allowed_values to a string and try to rebuild the field settings (with features and clear cache does it for me)

Proposed resolution

Cast the value to an array to avoid the error.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Needs review

Version

7.0 ⚰️

Component
FieldΒ  β†’

Last updated about 22 hours ago

Created by

πŸ‡¨πŸ‡¦Canada joelpittet Vancouver

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024