Problem/Motivation

Currently after every cache clear I see the following PHP warning:

Warning: Undefined array key "menu_link" in Drupal\ui_patterns\Plugin\Derivative\EntityReferencedDerivableContextDeriver->generateDefinitionsForReferencedEntityTypes() (line 137)

But this only happens on (e.g. node) pages where the Data from a field source is used somewhere for a property of a component (the actual selected field source may be anything).

Steps to reproduce

  • Create an entity with layout builder overrides enabled or configure a view mode with layout builder
  • Add a component and use Data from a field source for any of its properties and map any of the available fields
  • Open up the page where this layout is used
  • Clear all caches
  • Refresh the page where the layout is used and see the PHP warning

Proposed resolution

  • Check for any potential underlying issue and/or adjust code of EntityReferencedDerivableContextDeriver::generateDefinitionsForReferencedEntityTypes() to be more defensive, so it may handle this case by e.g. ignoring that specific field by checking $this->entityFieldsMetadata[$entity_type_id]["field_storages"] for the existence of the field before using it

Remaining tasks

  • Create issue fork an MR to fix this issue

User interface changes

n/a

API changes

n/a

Data model changes

n/a

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

hctom created an issue. See original summary.

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

just_like_good_vibes’s picture

Assigned: Unassigned » just_like_good_vibes

thanks for reporting, i will take this one

just_like_good_vibes’s picture

Assigned: just_like_good_vibes » pdureau
Status: Active » Needs review
hctom’s picture

Just tested the changes and the warning is gone in my case. Thanks a lot!

just_like_good_vibes’s picture

Assigned: pdureau » Unassigned
Status: Needs review » Fixed
pdureau’s picture

Title: Undefined array key "menu_link" in EntityReferencedDerivableContextDeriver::generateDefinitionsForReferencedEntityTypes() » [2.0.0-beta5] Undefined array key "menu_link" in EntityReferencedDerivableContextDeriver::generateDefinitionsForReferencedEntityTypes()
Status: Fixed » Closed (fixed)