This feels critical to me as it took a live site down, but change priority if needed.
Problem/Motivation
When deleting Event Series content, any associated Registrants are not deleted. When visiting parts of the website needing to get Registrant data, the missing Event Series cause their Registrants to produce an error:
Error: Call to a member function id() on null in Drupal\recurring_events_registration\Entity\Registrant->urlRouteParameters() (line 450 of /web/modules/contrib/recurring_events/modules/recurring_events_registration/src/Entity/Registrant.php)
Full error below
Steps to reproduce
- Create an Event Series with at least one Instance and with Registration enabled.
- Add Registrants to the Event Instance.
- Delete the Event Series
- Go to /admin/content/events/registrations and get WSOD
- Check log and see the error message
Manually deleting all registrants and associated field data from the database restores the page and stops errors from occurring.
Proposed resolution
When deleting Event Series, all Registrants of all Event Instances for the series should also be deleted.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | fix-fatal-error-on-non-catched-exception-3314032-6.patch | 1.08 KB | vlad.dancer |
| #17 | throw-exception-on-empty-eventinstance-url-param-3278860-13.patch | 1.46 KB | vlad.dancer |
Comments
Comment #2
chrisla commentedFull error message:
Comment #3
chrisla commentedComment #4
owenbush commentedThank you for raising this issue. I'll take a look at it as soon as I can.
Comment #5
owenbush commentedI have so far been unable to recreate this problem.
There is a hook 'recurring_events_registration_recurring_events_pre_delete_instances' which fires when a series entity is removed, which will delete the registrants prior to deleting the instances which itself happens prior to deleting the underlying series.
This seemed to fire for me when deleted through the Admin UI by clicking on Delete.
Did you do anything special when deleting? Like using views bulk operations, or doing it programmatically?
Hopefully we can figure out what is going on so I can address the problem.
Comment #6
chrisla commentedcannot replicate on a fresh install. was just deleting Event Series via its delete button. Will continue to investigate what is needed to reproduce
Comment #7
owenbush commentedThank you, I really appreciate that. I'll also keep an eye out for it.
Comment #8
christian deloach commentedI can confirm the same problem. Taking a look at the database I have three registrations. One of the registrations is linked (eventinstance_id) to an eventinstance that no longer exists. If I update the Registration view's relationships, changing the "Event Instance entity" to be required, the view displays without the above mentioned error, displaying the two registrations linked to eventinstance records that still exist in the database. It's possible this may have been caused by editing an event series with a recur type set to "Custom/Single Event". If the event date is changed, a warning is displayed that all instances will be removed and recreated. I suspect, but haven't confirmed through the code, the eventinstance record was removed but the registration was not deleted and the registration was not assigned the new eventinstance_id. I'm currently running on 2.0.0-rc3 but will update to 2.0.0-rc4 to see if recent updates (e.g. https://www.drupal.org/project/recurring_events/issues/3282741) may have address the issue.
Comment #9
vlad.dancerHm.. We run in the same issue but on updating Event Instance with single/custom events.
We are using also Autosave Form module that may conflict with Recurring Events.
From what I see Event Series had updated the date field but event instance is not.
Continue research on this.
Comment #10
owenbush commentedI just tried setting up an event series using the Custom/Single Event recurrence type, I then registered twice for an instance of that series. Then I updated the event series and changed the date, I was prompted as expected if I was sure I wanted to do this and that existing instances would be deleted, I continued and the event instance was removed as well as the two registrations.
So, I am still unable to reliably recreate this issue and I'm not sure why.
Comment #11
christian deloach commentedThank you Owen. I've not been able to replicate this on a clean installation using 2.0.0-rc4 so it's possible the issue may have been fixed between rc3 and rc4, maybe the committed patch in https://www.drupal.org/project/recurring_events/issues/3282741.
Comment #12
owenbush commentedYea maybe that was the underlying issue, lets keep this open for a while longer and if there are no further reports I'll close the issue out. Thanks for all involved for helping debug and troubleshoot.
Comment #13
vlad.dancerI'm not sure of the our issue related to the original one, if not feel free move it into a new issue.
But here is backtrace:
It seems that menu_link_content_entity_predelete tries to get referenced entities (registrations) too late?
So I've tried to fix
Registrant::urlRouteParameters()But then I have troubles with redirect_entity_delete() trying to lookup and delete redirect for registrant entity and
$entity->toUrl('canonical')->isRouted()causing fatal error. I see that redirect_entity_delete catches RouteNotFoundException here:But it seems that neither
hasLinkTemplate()nortoUrl()throws RouteNotFoundException. toUrl (by interface) should throw either UndefinedLinkTemplateException or EntityMalformedException exception.So I assume that redirect has wrong catch statement and should be updated.
Just for the test I've changed
Registrant::toUrl():And now all fatal errors were gone. I'm going to report an issue in redirect module too.
So the final fix should be:
Registrant.php
redirect.module
Need to test more cases for the fix above.
Comment #14
mikaylaflanagan commentedCan confirm this issue is still happening - just ran into the same issue today. The steps to reproduce listed above pretty much exactly match what caused this issue for me.
Comment #15
christian deloach commentedI too can confirm that this issue is still happening using rc5.
Comment #16
chrisla commentedComment #17
vlad.dancerWe are using one patch for recurring_events and one for redirect.
Comment #18
vlad.dancerAnd this one for redirect
Comment #19
owenbush commentedI think I may have found the source for the orphaned registrants that cause this issue.
I have created an MR in #3315836: Deleting old events with registrants that hopefully addresses the problem, and also provides a UI for cleaning up orphaned registrants and instances if some have ended up not getting deleted.
I haven't really had a chance to really review vlads patches and I will try and get to those later, but in the meantime we may be able to get out of the issue in a self-service manner.
Info is in the other issue.