Problem/Motivation
The form_mode_control_entity_delete function is called for all entity deletions (via hook_entity_delete), but it only needs to handle EntityFormDisplayInterface and RoleInterface. When other entities (like custom ones) are deleted, it still iterates the config, which can fail if the config has null values.
Steps to reproduce
Precondition: form_mode_control module enbled.
- Define a custom entity.
- Try to remove it.
The result: Warning: foreach() argument must be of type array|object, null given in form_mode_control_entity_delete()
Proposed resolution
Early return if entity is has no EntityFormDisplayInterface and RoleInterface.
if (!($entity instanceof EntityFormDisplayInterface) && !($entity instanceof RoleInterface)) {
return;
}
Comments
Comment #4
nickolajAdded early return checks to `form_mode_control_entity_delete()` to only process `EntityFormDisplayInterface` and `RoleInterface` entities, and to handle cases where the `defaults` configuration is empty or null.
Comment #5
pcfoster commentedPatched successfully, verified fixed the warnings been thrown in the three context we ran into it (syncing local from upstream db, a VBO job, rebuilding tracking info in search api). Thx!
Comment #7
dieterholvoet commentedThanks!