Skip to content
New issue

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

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

Already on GitHub? # to your account

[8.x] Avoid SwiftMailer forceReconnection when not running from a queue daemon #36709

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Illuminate/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Illuminate\Contracts\View\Factory;
use Illuminate\Mail\Events\MessageSending;
use Illuminate\Mail\Events\MessageSent;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Traits\Macroable;
use InvalidArgumentException;
Expand Down Expand Up @@ -520,7 +521,9 @@ protected function sendSwiftMessage($message)
try {
return $this->swift->send($message, $this->failedRecipients);
} finally {
$this->forceReconnection();
if (Config::get('app.is_run_from_queue_daemon', false)) {
Copy link
Member

Choose a reason for hiding this comment

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

We can't use a facade like this here since the mailer component also can act as a standalone component.

$this->forceReconnection();
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/Illuminate/Queue/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Illuminate\Queue\Events\Looping;
use Illuminate\Queue\Events\WorkerStopping;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Config;
use Throwable;

class Worker
Expand Down Expand Up @@ -116,6 +117,10 @@ public function __construct(QueueManager $manager,
*/
public function daemon($connectionName, $queue, WorkerOptions $options)
{
if ($connectionName !== 'sync') {
Config::set('app.is_run_from_queue_daemon', true);
Copy link
Member

Choose a reason for hiding this comment

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

Same here. We can't use a facade here.

}

if ($this->supportsAsyncSignals()) {
$this->listenForSignals();
}
Expand Down