Unverified Commit da3bf5a1 authored by Kevin Dutra's avatar Kevin Dutra Committed by Jonathan Hedstrom
Browse files

Issue #3319537 by kevin.dutra: Queue items become stuck if a recipient user is deleted

parent bb80e1d0
Loading
Loading
Loading
Loading
+9 −1
Changes for src/MassContact.php: 9 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -271,18 +271,26 @@ class MassContact implements MassContactInterface {
      foreach ($recipients as $recipient) {
        /** @var \Drupal\user\UserInterface $account */
        $account = $this->entityTypeManager->getStorage('user')->load($recipient);
        if ($account) {
          $emails[] = $account->getEmail();
        }
      }
      if (count($emails) > 0) {
        $params['headers']['Bcc'] = implode(',', array_unique($emails));
      $this->mail->mail('mass_contact', 'mass_contact', $configuration['sender_mail'], \Drupal::languageManager()->getDefaultLanguage()->getId(), $params);
        $this->mail->mail('mass_contact', 'mass_contact', $configuration['sender_mail'], \Drupal::languageManager()
          ->getDefaultLanguage()
          ->getId(), $params);
      }
    }
    else {
      foreach ($recipients as $recipient) {
        /** @var \Drupal\user\UserInterface $account */
        $account = $this->entityTypeManager->getStorage('user')->load($recipient);
        if ($account) {
          $this->mail->mail('mass_contact', 'mass_contact', $account->getEmail(), $account->getPreferredLangcode(), $params);
        }
      }
    }
  }

}