Error: Call to a member function getEntityTypeId() on null in Drupal\entity_usage\Controller\LocalTaskUsageController->checkAccessLocalTask() (line 26 of .../src/Controller/LocalTaskUsageController.php)

Created on 8 July 2025, 1 day ago

Problem/Motivation

When I try and edit an existing paragraph using Drupal 11.2.2 and entity_usage 2.0.0-beta24 I see the error:
Error: Call to a member function getEntityTypeId() on null in Drupal\entity_usage\Controller\LocalTaskUsageController->checkAccessLocalTask() (line 26 of .../src/Controller/LocalTaskUsageController.php)

I no longer have access to the local tasks such as 'manage form display' and 'manage display' as well.

Steps to reproduce

Install Drupal 11.2.2.
Install Paragraphs 1.19.0
Create a paragraph with some fields.
Install Entity Usage 2.0.0-beta24
Enable entity usage on paragraphs
Try to edit the paragraph you created.
You will see the error at the bottom of the screen and in the log messages.

Proposed resolution

I'm unsure if it's the correct approach but the issue can be resolved by adding some defensive checks in LocalTaskUsageController.php although someone with a deeper understanding of the module should check if this approach is appropriate, safe, and robust.

Remaining tasks

I will create a branch and MR to demonstrate how I've fixed this.
This will need to be reviewed.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom d.fisher

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