Problem/Motivation

Previously, the registration creation service would almost be guaranteed to have an event instance or series stored. This was not a good practice and fixed by https://www.drupal.org/project/recurring_events/issues/3452632

In the service's retrieveRegisteredParties() method, the old assumption that an event instance would be present seems to still be in effect. Now, if an event instance has not been stored, retrieveRegisteredParties() will return every single registrant from across the whole site's history. Reviewing the use of retrieveRegisteredParties(), I don't think retrieving all registrants is ever a desired result. I believe this method should fail if an event instance is not specified.

If needed, we could add something like retrieveAllRegisteredParties() for the task of getting site-wide registrants.

Steps to reproduce

In some custom code, load the registration creation service and call retrieveRegisteredParties() method. You will get all registrants on the site, unrestricted to any event.

Proposed resolution

Include a check to retrieveRegisteredParties() whether an event instance is stored. If not, return an exception.

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

chrisla created an issue. See original summary.

chrisla’s picture

Status: Active » Needs review
StatusFileSize
new1.68 KB

attached patch does what I suggest. please advise if a different way of throwing the exception is recommended.

carolpettirossi’s picture

I had an issue where the site was sending emails to all registrants when a series that doesn't have registration enabled got updated.

The suggested patch did not solve my case. What solved my issue was adding a validation:

   if(!$this->getRegistrationType()) {
      return [];
    }

chrisla’s picture

Requesting review and merge