Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array

Created on 7 November 2025, 4 days ago

Problem/Motivation

PHP Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /var/www/html/web/modules/contrib/entity_usage/src/Routing/RouteSubscriber.php:59
Stack trace:
#0 /var/www/html/web/modules/contrib/entity_usage/src/Routing/RouteSubscriber.php(59): in_array()
#1 /var/www/html/web/core/lib/Drupal/Core/Routing/RouteSubscriberBase.php(37): Drupal\entity_usage\Routing\RouteSubscriber->alterRoutes()

Steps to reproduce

1. Use Drupal core verson: 11.2.7
2. Install entity_usage module
3. Clear cache

Proposed resolution

if (!in_array($entity_type_id, $configured_types, TRUE)) {
continue;
}

if (empty($template) || !in_array($entity_type_id, $configured_types, TRUE)) {
continue;
}
TO

if (!in_array($entity_type_id, $configured_types ?? [], TRUE)) {
continue;
}
if (empty($template) || !in_array($entity_type_id, $configured_types ?? [], TRUE)) {
continue;
}

🐛 Bug report
Status

Active

Component

Code

Created by

🇮🇳India shashank5563 New Delhi

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