"TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given" in hook_entity_base_field_info() implementation

Created on 1 August 2025, 3 months ago

Problem/Motivation

When FieldInheritanceHooks::entityBaseFieldInfo() runs, it generates the following error:

TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in /var/www/html/web/modules/contrib/field_inheritance/src/Hook/FieldInheritanceHooks.php on line 82 #0 /var/www/html/web/modules/contrib/field_inheritance/src/Hook/FieldInheritanceHooks.php(82): in_array()

This is due to the fact that the list of included entities is imploded into a comma-separated list when saving to config but not exploded again after reading from config.

Steps to reproduce

Ensure a value is set for "field_inheritance.config:included_entities"
Execute "drush cim".
The command fails with the error above.

Proposed resolution

Explode the included_entities value into an array before calling in_array()

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States byrond

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