Problem/Motivation
The RegistrationCreationService is a stateful object which stores data internally. Since the service is not declared as a non-shared service, it is leaking its state to any code that retrieves the service from the container.
Steps to reproduce
// Run some code that sets an event instance on the service (e.g. `EventInstanceCapacity::render()`).
// ...
// Now in some later running code retrieve the service.
$service = \Drupal::service('recurring_events_registration.creation_service')
// We should have a clean instance of the service, but the data from the previous code is still present.
assert(empty($service->getEventInstance()), 'No data is leaked between uses of the service');
Proposed resolution
Mark the service as non-shared.
Issue fork recurring_events-3452632
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 #2
pfrenssenComment #4
pfrenssenAdded a failing test that showcases the problem:
https://git.drupalcode.org/issue/recurring_events-3452632/-/jobs/1783093
Comment #5
pfrenssenDefining the service as non-shared solves the problem. The test passes now: https://git.drupalcode.org/issue/recurring_events-3452632/-/jobs/1783235
The other test failures are not related to this issue, ref. #3452641: Failing tests on main branch
Comment #6
owenbush commentedThanks for this I'll get this merged.
Comment #8
owenbush commentedThis has been merged.