Problem/Motivation

EventInstances::computeValue() generates an item list keyed by event instance entity IDs. This means that $event_series->event_instances->referencedEntities() doesn't conform to the expectations for the return value of EntityReferenceFieldItemListInterface::referencedEntities(), which is supposed to be "An array of entity objects keyed by field item deltas." This in turn breaks any code that expects the first instance to be delta 0; e.g., $event_series->event_instances->referencedEntities()[0]->label().

Proposed resolution

Change EventInstances::computeValue() to return an array with standard delta keys (0, 1, ...), sorted by instance start date.

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

muriqui created an issue. See original summary.

muriqui’s picture

Status: Active » Needs review

Proposed fix in MR !57 (including a couple of coding standards fixes in EventInstances.php).

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

  • owenbush committed fbca4b2 on 2.0.x authored by muriqui
    Issue #3320512 by muriqui: EventInstances field keys don't conform to...

  • owenbush committed 25378b9 on 8.x-1.x authored by muriqui
    Issue #3320512 by muriqui: EventInstances field keys don't conform to...
owenbush’s picture

Status: Needs review » Fixed

Thanks for this issue, I checked through the code to ensure there were no expectations of data being keyed by eventinstance_id and it looked like there weren't, so I have merged this into the latest dev branches for 8.x-1.x and 2.0.x

Status: Fixed » Closed (fixed)

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