Problem/Motivation

An unfortunate combination of core, (contrib) and custom code leads to an infinite loop when sending out newsletters. In order to mitigate the problem it would be very useful if simplenews would use strict comparison operators when checking for errors.

If any hook_mail_alter implementation sets $message['send']=FALSE. Then the following happens:

  1. MailManager::doMail() sets $message['result'] to NULL.
          // The original caller requested sending. Sending was canceled by one or
          // more hook_mail_alter() implementations. We set 'result' to NULL,
          // because FALSE indicates an error in sending.
          if (empty($message['send'])) {
            $message['result'] = NULL;
          }
    
  2. Mailer::sendMail() thinks that there was an error and schedules the message to be sent again if $message['result'] evaluates to a falseish value.
          // By default, failures are left in PENDING state to retry.
          $result = $message['result'] ? SpoolStorageInterface::STATUS_DONE : SpoolStorageInterface::STATUS_PENDING;
          $this->moduleHandler->alter('simplenews_mail_result', $result, $message);
    

Steps to reproduce

Proposed resolution

Use strict comparison. I.e.:

$result = $message['result'] === FALSE ? SpoolStorageInterface::STATUS_PENDING : SpoolStorageInterface::STATUS_DONE;

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#6 simplenews.message-result.3307324-6.patch641 bytesadamps

Comments

znerol created an issue. See original summary.

znerol’s picture

Issue summary: View changes
znerol’s picture

Issue summary: View changes
znerol’s picture

Issue summary: View changes
adamps’s picture

Version: 3.x-dev » 4.x-dev

Seems like a good idea

adamps’s picture

Status: Active » Needs review
StatusFileSize
new641 bytes

  • AdamPS committed 7a70bb37 on 4.x
    Issue #3307324 by AdamPS, znerol: Use strict check on $message['result...
adamps’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.