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.

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

john.oltman created an issue. See original summary.

daniel.pernold made their first commit to this issue’s fork.

daniel.pernold’s picture

Status: Active » Needs review

Here 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:

  • New setting purge_registration_on_registrant_delete in registration_purger.settings (schema, install config, registration_purger_update_10002()). The default is FALSE, so existing sites keep their registrations until they opt in.
  • A new fieldset "On registrant delete" with a "Purge registrations" checkbox in the purger section of the registration settings form.
  • RegistrationPurger::onEntityDelete() calls the new purgeRegistrantRegistrations() 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 (as RegistrationManager::syncRegistrantAccount() does) and deletes the registrations of those types whose registrant is the deleted entity. For user registrants the registrant mirrors user_uid, so deleting a user purges that user's registrations.
  • purgeRegistrantRegistrations() is added to RegistrationPurgerInterface, next to purgeSettings() and purgeRegistrations().
  • Kernel test 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 TRUE for 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) ?? $default casts before the null coalescing operator, so $default is never used when a setting is missing.