Uncaught PHP Exception TypeError: "array_keys(): Argument #1 ($array) must be of type array, null given" at /master/web/modules/contrib/views_entity_form_field/views_entity_form_field.module line 77

Created on 20 September 2025, 17 days ago

Problem/Motivation

When the Profile module is installed, it introduces the profile entity type, which initially has no bundles or fields.
The Views Entity Form Field moduleโ€™s hook_views_data_alter() calls array_keys() on $bundle_info[$entity_type_id].
At that stage, $bundle_info['profile'] is NULL, causing the fatal error:

Uncaught PHP Exception TypeError: "array_keys(): Argument #1 ($array) must be of type array, null given"

Steps to reproduce

Install Profile module.
Without creating any Profile types/fields, enable Views Entity Form Field.
Observe site crash with above error.
The code directly calls:

'bundles' => array_keys($bundle_info[$entity_type_id]),

without verifying if $bundle_info[$entity_type_id] exists or is an array.
The module should gracefully skip entity types with no bundle info, instead of throwing a TypeError.

Proposed resolution

Wrap the array_keys() call with a check:

// Add submit button for row.
if (isset($bundle_info[$entity_type_id]) && is_array($bundle_info[$entity_type_id])) {
  $data[$views_table]['form_field_submit_row']['field'] = [
    'title' => t('Form field: Submit button'),
    'help' => t('Add a submit button to the row.'),
    'id' => 'entity_form_field',
    'bundles' => array_keys($bundle_info[$entity_type_id]),
    'entity_type' => $entity_type_id,
    'field_name' => 'form_field_submit_row',
  ];
}

๐Ÿ› Bug report
Status

Needs review

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia ali rizvi

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024