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

class SetQueue not found origination from the Mail facade #26136

Closed
connor-simpson opened this issue Oct 16, 2018 · 13 comments
Closed

class SetQueue not found origination from the Mail facade #26136

connor-simpson opened this issue Oct 16, 2018 · 13 comments

Comments

@connor-simpson
Copy link

Hi all,

Can anyone shed some light on why the Mail facade is spewing out that a certain SetQueue class cannot be found? I haven't changed anything code wise, it weirdly started happening overnight.

I've tried to clear my composer cache and reinstall all the repositories and dumped the auto-load etc but I can't seem to get it working 👎 .

Anyone else having the same problem or experienced this?

The traceback can be found here.

@driesvints
Copy link
Member

Hi there,

Looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs or problems. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

@patrickomeara
Copy link
Contributor

patrickomeara commented Dec 5, 2018

@Cranavvo I'm having this same issue after updating to PHP 7.3. I have no changes in the codebase. I've tried changing the MAIL_DRIVER and QUEUE_CONNECTION env vars, but nothing seems to work.

Did you find a solution?

@grund3g
Copy link

grund3g commented Dec 7, 2018

@patrickomeara same here after upgrading to PHP 7.3

@driesvints
Copy link
Member

Okay I'll have a look at this. I'll need more info and/or code to debug this further. Please post relevant code like models, jobs, commands, notifications, events, listeners, controller methods, routes, etc. You may use https://paste.laravel.io to post larger snippets or just reply with shorter code snippets. Thanks!

@driesvints driesvints reopened this Dec 7, 2018
@grund3g
Copy link

grund3g commented Dec 7, 2018

To give it a little more context. It concerns an app that was updated from Laravel 5.5 to 5.7. PHP has been updated from 7.1 to 7.3.

I changed QUEUE_DRIVER to QUEUE_CONNECTION. The config is cleared / cached at every deploy.

It's odd that sometimes it works (same model, same mail) without any problems. I thought it might have something to do with OPcache. So now I also clear the OPcache with a command (opcache_reset()) after every deploy, in addition to the FPM restart from the envoyer script.

Here is an error message: https://paste.laravel.io/0603b738-da94-452f-bc73-a54cdde4398f

@driesvints
Copy link
Member

Which queue connection are you using? Did you modify the queue config from the base laravel skeleton? Can you post the code of the NewsflowController and the NewsflowArticle classes? Are you overwriting the Mailer class? Are you using macros on the Mailer class?

@grund3g
Copy link

grund3g commented Dec 7, 2018

I am using redis (horizon). I updated the config/queue.php file with the latest changes from Laravel 5.7. No macros or changes to the Mailer class.

NewsflowController

<?php

namespace App\Http\Controllers;

use App\Models\NewsflowArticle;
use App\Models\NewsflowSubscription;
use Illuminate\Support\Facades\Mail;
use App\Mail\Newsflow\NewsflowNotification;

class NewsflowController extends Controller
{
    ///
    ///

    protected function sendPushNotifications(NewsflowArticle $article)
    {
        $subscriptions = NewsflowSubscription::where('confirmed', true)->where('interval', 'push')->get();

        foreach ($subscriptions as $subscription) {
            Mail::to($subscription->email)->send(new NewsflowNotification($subscription, 'push', $article));
        }
    }

NewsflowArticle and NewsflowSubscription are just two base Eloquent Models without any modification.

App\Mail\Newsflow\NewsflowNotification.php

<?php

namespace App\Mail\Newsflow;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class NewsflowNotification extends Mailable implements ShouldQueue
{
    use Queueable, SerializesModels;

    public $subscription;

    public $article;

    public $interval;

    public function __construct($subscription, $interval, $article)
    {
        $this->subscription = $subscription;

        $this->interval = $interval;

        $this->article = $article;
    }

    public function build()
    {
        return $this->view('emails.newsflow.notification');
    }
}

@driesvints
Copy link
Member

Did you restart horizon and purged any orphan processes with horizon:purge?

@connor-simpson
Copy link
Author

I'm not using queues of any sort in my application... my shitty solution was opening up the MailServiceProvider in Laravel (vendor/laravel) and commenting out this:

if ($app->bound('queue')) {
     $mailer->setQueue($app['queue']);
}

I'm still cursed to this day, an error will trigger every time to Mail facade is used (if the code above isn't commented out).

@grund3g
Copy link

grund3g commented Dec 7, 2018

Yes, with the following after each deploy:

php artisan horizon:purge
php artisan horizon:terminate

@grund3g
Copy link

grund3g commented Dec 7, 2018

I'm actually pretty sure it has nothing to do with the framework itself. It's just very strange that it happened so suddenly after upgrading to PHP 7.3. Had no problem the whole day with this error and the mails were sent without problems. Just now the error occurred again. After I restarted nginx, everything works again.

@driesvints
Copy link
Member

I'm going to close this off then if this problem was resolved. Could have been a hiccup with the upgrade to 7.3? Let me know if the problem persists.

@more-yogesh
Copy link

For MacBook Users just use command "valet restart" In my case, it's working now. Try to restart your server that might be helpful.

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

No branches or pull requests

5 participants