Problem/Motivation
Currently when a user or other registrant type is deleted, the registrations for that user remain in the system with a dangling reference.
It would be nice if the Registration Purger submodule had an option to delete the user's associated registrations when the user is deleted.
Steps to reproduce
Register a user for an event. Delete the user. Visit the Manage Registrations page for the event and see the registration is there with an empty column for the User or Registrant.
Proposed resolution
Add another fieldset to the Purger settings with options to purge Registrations for a deleted registrant.
Once entities other than users can be registered (coming soon) this should apply to non-user registrants as well.
Remaining tasks
Create a merge request.
User interface changes
More purger settings.
API changes
None
Data model changes
None.
Issue fork registration-3624648
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
Comment #4
daniel.pernold commentedHere is a merge request for this. Now that #1653458: Register an entity different than a user is in 3.4.x, it covers all registrant entity types, not only users:
purge_registration_on_registrant_deleteinregistration_purger.settings(schema, install config,registration_purger_update_10002()). The default isFALSE, so existing sites keep their registrations until they opt in.RegistrationPurger::onEntityDelete()calls the newpurgeRegistrantRegistrations()for content entities when the setting is on. It looks for the registration types whose registrant entity type is the type of the deleted entity (asRegistrationManager::syncRegistrantAccount()does) and deletes the registrations of those types whoseregistrantis the deleted entity. For user registrants the registrant mirrorsuser_uid, so deleting a user purges that user's registrations.purgeRegistrantRegistrations()is added toRegistrationPurgerInterface, next topurgeSettings()andpurgeRegistrations().RegistrationPurgerTest::testRegistrationPurgerOnRegistrantDelete(): the registrations of a deleted user are kept with the setting off and purged with it on, while the registrations of other users and the host settings are not touched. Node registrants are purged as well, but a user-registrant registration with the same ID is not.Open question: should the default be
TRUEfor new installs, like the host entity delete settings? I kept it off because it deletes data that sites currently keep.Side note, not changed in the MR: in
RegistrationPurger::isEnabled(),(bool) $this->configFactory->get(...)->get($setting) ?? $defaultcasts before the null coalescing operator, so$defaultis never used when a setting is missing.