PluginNotFoundException: Non-existent Entity Type in Site Audit Module Field Map Processing

Created on 13 March 2025, about 1 month ago

Problem/Motivation

When running the Site Audit module in Drupal 10, the following error occurs during the calculateScore() method execution:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "custom_entity" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 142 of /core/lib/Drupal/Core/Entity/EntityTypeManager.php).

Steps to reproduce

The issue arises because the calculateScore() method processes all field mappings retrieved from entity_field.manager->getFieldMap(). This includes field configurations for entity types that no longer exist in the system (e.g., due to improper uninstallation of a module or custom entity type). When attempting to retrieve the definition of a non-existent entity type using entity_type.manager->getDefinition(), a PluginNotFoundException is thrown.

Proposed resolution

Add a check to ensure that only existing entity types are processed. Modify the calculateScore() method to skip non-existent entity types using the hasDefinition() method of the entity_type.manager service.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

4.0

Component

Code

Created by

🇯🇴Jordan mohammad-fayoumi Amman

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