- Issue created by @pfrenssen
- Merge request !97Fix fatal error when translating event series that references an event... β (Open) created by pfrenssen
- Status changed to Needs review
6 days ago 4:56pm 22 June 2024
When an event series is translated we also need to create translations for each event instance. This work fine, except when an event instance belonging to the series has been changed after initial creation. Then a fatal type error occurs:
TypeError: Drupal\recurring_events\EventCreationService::configureDefaultInheritances(): Argument #1 ($instance) must be of type Drupal\recurring_events\Entity\EventInstance, null given, called in /app/drupal/docroot/modules/contrib/recurring_events/src/EventCreationService.php on line 509 in Drupal\recurring_events\EventCreationService->configureDefaultInheritances() (line 598 of modules/contrib/recurring_events/src/EventCreationService.php).
Expected result: the Italian translation is created.
Actual result: the error above is thrown.
Currently when an event series is translated, we are calling EventCreationService::createInstances()
which is intended to be used for populating event instances on a newly created event series. The logic in this method derives the start and end dates for the event instance dates from the data entered in the form, and later on tries to match these up to existing event instances. This will fail when event instances have been modified.
We should instead iterate over the existing event instances that are referenced on the event series. This is simple and reliable.
The recurring_events_event_instance
alter hook no longer fires when an event instance is translated, but the documentation for recurring_events_event_instance()
indicates that this was not the intention, but that this is only intended for altering event instances that are generated when a new event series is created.
Needs review
2.0
Recurring Events (Main module)