Reminder cron exits early if one event instance lacks registrants

Created on 6 September 2025, about 2 months ago

Problem/Motivation

In recurring_events_reminders_cron, if one of the event instances marked for sending reminders has no registrants, the loop breaks and the remaining instances in the list are left unprocessed. As a result, you must wait until the next cron run, hoping that no other empty instances are encountered, before the reminders for valid instances are eventually processed and notifications are sent.

This happens because the function uses return instead of continue at this point in the code:
recurring_events_reminders/recurring_events_reminders.module

    foreach ($instances as $instance) {
      $instance->set('reminder_sent', time());
      $instance->setNewRevision(FALSE);
      $instance->save();

      /** @var \Drupal\recurring_events_registration\RegistrationCreationService */
      $registration_creation_service = \Drupal::service('recurring_events_registration.creation_service');
      $registration_creation_service->setEventInstance($instance);

      $registrants = $registration_creation_service->retrieveRegisteredParties();

      if (empty($registrants)) {
        return; // This breaks the process if an instance has no registrants, leaving remaining instances unprocessed.
      }

      $key = 'registration_reminder';

      // Send an email to all registrants.
      foreach ($registrants as $registrant) {
        // Add each notification to be sent to the queue.
        \Drupal::service('recurring_events_registration.notification_service')->addEmailNotificationToQueue($key, $registrant);
      }
    }

Steps to reproduce

  1. Create a series with reminders enabled and multiple instances.
  2. Add a couple of registrants to the last instance in the series.
  3. Leave the other instances without registrants.
  4. Run cron, expecting the reminders to be sent to the registrants you created.
  5. Notice that execution breaks when it encounters the first instance without registrants.
  6. Observe that cron must be run several times before it eventually reaches the instance with registrants and sends the reminders.

Proposed resolution

If an instance does not have registrants, the process should continue with the next instance in the list.
Replace return with continue.

Remaining tasks

Create MR.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Active

Version

2.0

Component

Recurring Events Reminders (Submodule)

Created by

🇨🇴Colombia camilo.escobar

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024