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.

  1. Define a custom entity.
  2. 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;
}
Command icon 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

le72 created an issue. See original summary.

nickolaj made their first commit to this issue’s fork.

nickolaj’s picture

Status: Active » Needs review

Added 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.

pcfoster’s picture

Status: Needs review » Reviewed & tested by the community

Patched 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!

dieterholvoet’s picture

Status: Reviewed & tested by the community » Fixed

Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.