Problem/Motivation
Any Edit form for an entity that has a lot of usages start to load slower, even causing the WSOD with 500 HTTP code.
Profiler log:

Steps to reproduce
1. Remove the listSources call
Remove the listSources call entirely from entity_usage_form_alter:
<?php
$usage_data = \Drupal::service('entity_usage.usage')->listSources($entity);
if (empty($usage_data)) {
return;
}
?>
Reasoning:
It makes little sense to load thousands of entities simply to conditionally display a warning message.
Given that this warning does not block editing or saving, it is impractical to force a wait time of 10–100+ seconds just to decide whether to show a message.
Additionally, the $usage_data variable is not utilized in the error message text or anywhere else in the function.
2. Updated Message Wording
a. Edit Warning:
Current: Modifications on this form will affect all existing usages of this entity.
Suggested: Modifications made here may affect all existing usages of this entity.
b. Deletion/Recorded Usages:
Current: There are recorded usages of this entity.
Suggested: There may be recorded usages of this entity. Please verify usage before proceeding with deletion.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| Zrzut ekranu 2026-04-8 o 15.08.59.png | 173.34 KB | dmitry.korhov |
Issue fork entity_usage-3583694
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
dmitry.korhovComment #6
alexpott@dmitry.korhov this is a nice find and can be improved - however I think can keep the current messages and functionality.
I've pushed an alternate fix that limits the query to 1 row which will be quick.
Comment #9
alexpottComment #12
dmitry.korhov@alexpott,
limit makes sense, especially having listSources supports limit already.
Thank you for fix!