Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure there are no emails without recipient in email queue #1109

Conversation

lemundo-team
Copy link
Contributor

@lemundo-team lemundo-team commented Jul 13, 2020

Additional check of email recipients in order to ensure there are no invalid emails without recipient in queue

Description (*)

It appeared several times that there are emails without recipients in the emails queue - even if the email address is mandatory for checkout. This pull request is not fixing the origin issue but it ensures that this one wrongly added email is not blocking all queued emails which is leading to unsatisfied customers.
Consider it more as a security improvement to keep the shop running.

Manual testing scenarios (*)

There is no known test scenario but it is solving issues that happens once every 2000 orders.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)

Copy link
Contributor

@kiatng kiatng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kiatng kiatng added the Component: Core Relates to Mage_Core label Jul 14, 2020
@@ -238,13 +238,13 @@ public function send()

try {
$mailer->send();
unset($mailer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why move the unset?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -238,13 +238,13 @@ public function send()

try {
$mailer->send();
unset($mailer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fballiano fballiano merged commit e286008 into OpenMage:1.9.4.x May 28, 2022
@github-actions
Copy link
Contributor

Unit Test Results

1 files  1 suites   0s ⏱️
0 tests 0 ✔️ 0 💤 0 ❌
7 runs  5 ✔️ 2 💤 0 ❌

Results for commit e286008.

@luigifab
Copy link
Contributor

luigifab commented Jun 9, 2022

The move of the unset is wrong no?

try {
$mailer->send();
unset($mailer);
$message->setProcessedAt(Varien_Date::formatDate(true));
$message->save(); // save() is throwing exception when recipient is not set
} catch (Exception $e) {
Mage::logException($e);
}

On exception, variable is not unset.

@addison74
Copy link
Contributor

addison74 commented Jun 9, 2022

@luigifab - the author can tell us why he moved in exception. Maybe it was better to leave it where it was before.

@colinmollenhour
Copy link
Member

Agreed with the change overall. Not sure if the location of the unset matters much, the PHP garbage collector should be able to clean it up either way I think.

@leissbua
Copy link
Contributor

leissbua commented Aug 13, 2022

i think the whole solution does not work nor is well tested - remove an recipient and the queue processing is brought to an end:

---EXCEPTION---
Mage_Core_Exception: Message recipients data must be set. in /home/cloudpanel/htdocs/www.domain.com/app/Mage.php:656
Stack trace:
#0 /home/cloudpanel/htdocs/www.domain.com/app/code/core/Mage/Core/Model/Email/Queue.php(99): Mage::throwException('Message recipie...')
#1 /home/cloudpanel/htdocs/www.domain.com/app/code/core/Mage/Core/Model/Abstract.php(329): Mage_Core_Model_Email_Queue->_beforeSave()

This was happening first time on a store running since 10 years with 1k plus oders a day. We never had problems until today.

We should better quality test code changes, because i have the feeling quality is going down.

@kiatng
Copy link
Contributor

kiatng commented Aug 14, 2022

@leissbua Sorry for the problem you face. How do you remove a recipient? Was it the first recipient that was removed? Does it throw the exception when the second or third recipient is removed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants