Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jaswsinc committed Feb 15, 2016
1 parent fd4b4ea commit 90b9d23
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/includes/classes/QueueProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,10 @@ protected function maybeProcess()
$this->total_entries = count($this->entries);

foreach ($this->entries as $_entry_id_key => $_entry) {
$this->processEntry($_entry);
$this->deleteEntry($_entry);
if ($this->processEntry($_entry)) {
$this->deleteEntry($_entry);
} // Do not delete those being held over.
// See: <https://github.com/websharks/comment-mail/issues/173>

++$this->processed_entry_counter;

Expand All @@ -226,43 +228,50 @@ protected function maybeProcess()
* @since 141111 First documented version.
*
* @param \stdClass $entry Queue entry.
*
* @return bool True if OK to delete; i.e., if entry was logged in some way.
* This will return `false` if it is not OK to delete; e.g., being held over.
*/
protected function processEntry(\stdClass $entry)
{
if ($entry->dby_queue_id || $entry->logged) {
return; // Already processed this.
return true; // Already processed this.
}
if (!($entry_props = $this->validatedEntryProps($entry))) {
return; // Bypass; unable to validate entry props.
return true; // Bypass; unable to validate entry props.
}
if ($this->checkEntryHoldUntilTime($entry_props)) {
return; // Holding (for now); nothing more.
return false; // Holding (for now).
}
$this->checkCompileEntryDigestableEntries($entry_props);

if (!($entry_headers = $this->entryHeaders($entry_props))) {
$entry_props->event = 'invalidated'; // Invalidate.
$entry_props->note_code = 'comment_notification_headers_empty';

$this->logEntry($entry_props); // Log invalidation.
return; // Not possible; headers are empty.
return true; // Not possible; headers are empty.
}
if (!($entry_subject = $this->entrySubject($entry_props))) {
$entry_props->event = 'invalidated'; // Invalidate.
$entry_props->note_code = 'comment_notification_subject_empty';

$this->logEntry($entry_props); // Log invalidation.
return; // Not possible; subject line is empty.
return true; // Not possible; subject line is empty.
}
if (!($entry_message = $this->entryMessage($entry_props))) {
$entry_props->event = 'invalidated'; // Invalidate.
$entry_props->note_code = 'comment_notification_message_empty';

$this->logEntry($entry_props); // Log invalidation.
return; // Not possible; message body is empty.
return true; // Not possible; message body is empty.
}
$entry_props->event = 'notified'; // Notifying now.
$entry_props->note_code = 'comment_notification_sent_successfully';
$this->logEntry($entry_props); // Log successful processing.

$this->logEntry($entry_props); // Log successful processing.
$this->plugin->utils_mail->send($entry_props->sub->email, $entry_subject, $entry_message, $entry_headers);
return true; // Notified; OK to delete this entry now.
}

/**
Expand Down

0 comments on commit 90b9d23

Please sign in to comment.