NotificationService leaks state

Created on 30 September 2024, 8 months ago

Problem/Motivation

The NotificationService in the recurring_event_registration module is keeping local state but is stored on the dependency injection container as a reusable singleton. This causes it to leak it state in between calls. We should mark the service as non-shared, similar to what was done in 🐛 Registration creation service leaks data Fixed .

Even though this is a defect and the internal state of the service cannot be relied upon, there might be existing project code in the wild that is written expecting the state to be present, so this is a potential B/C break. We should fix this in the major 3.x release.

Let's also pay some attention to the RegistrantResendForm that also seems to rely on a prefilled state.

Steps to reproduce

// Run some code that instantiates the service (e.g. `recurring_events_registration_send_notification()`).
// ...

// Now in some later running code retrieve the service.
$service = \Drupal::service('recurring_events_registration.notification_service');

// We should have a clean instance of the service, but the data from the previous code is still present.
assert($service->getKey() === FALSE, 'No data is leaked between uses of the service');

Proposed resolution

Mark the service as non-shared.

🐛 Bug report
Status

Active

Version

3.0

Component

Recurring Events Registration (Submodule)

Created by

🇧🇬Bulgaria pfrenssen Sofia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024