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

Queueing email fails with PHP 7.3: Class setQueue does not exist #26819

Closed
ThomHurks opened this issue Dec 12, 2018 · 75 comments
Closed

Queueing email fails with PHP 7.3: Class setQueue does not exist #26819

ThomHurks opened this issue Dec 12, 2018 · 75 comments
Labels

Comments

@ThomHurks
Copy link
Contributor

ThomHurks commented Dec 12, 2018

  • Laravel Version: 5.7.17
  • PHP Version: 7.3
  • Database Driver & Version: MySQL 5.7

Description:

When using Laravel with PHP 7.3, you get an error when queueing emails. I'm using a Redis queue for this. With PHP 7.2 everything works fine.

Steps To Reproduce:

I get an error on the line:

Mail::to($user->email)->send(new FooMail($user));

where Mail is Illuminate\Support\Facades\Mail

the class FooMail:

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

class FooMail extends Mailable implements ShouldQueue
{
    use Queueable, SerializesModels;
    public function build() {
      return $this->view('emails.foo')->subject(...)->replyTo(...)->with([...]);
    }
}

My config:

MAIL_DRIVER=smtp
MAIL_HOST=email_host
MAIL_PORT=25
MAIL_USERNAME=username
MAIL_PASSWORD=secret
MAIL_ENCRYPTION=tls
MAIL_FROM_NAME='Foo Bar'

CACHE_DRIVER=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis

REDIS_HOST=redis-master
REDIS_PASSWORD=null
REDIS_PORT=6379
REDIS_QUEUE=default

Furthermore I'm using phpredis as the client, not predis.

When I send an email I get the following error:

[2018-12-12 19:05:17] local.ERROR: Class setQueue does not exist {"exception":"[object] (ReflectionException(code: -1): Class setQueue does not exist at /Users/thom/Sites/fooProject/vendor/laravel/framework/src/Illuminate/Container/Container.php:779)
[stacktrace]
#0 /Users/thom/Sites/fooProject/vendor/laravel/framework/src/Illuminate/Container/Container.php(779): ReflectionClass->__construct('setQueue')
#1 /Users/thom/Sites/fooProject/vendor/laravel/framework/src/Illuminate/Container/Container.php(658): Illuminate\\Container\\Container->build('setQueue')
#2 /Users/thom/Sites/fooProject/vendor/laravel/framework/src/Illuminate/Container/Container.php(609): Illuminate\\Container\\Container->resolve('setQueue', Array)
#3 /Users/thom/Sites/fooProject/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(733): Illuminate\\Container\\Container->make('setQueue', Array)
#4 /Users/thom/Sites/fooProject/vendor/laravel/framework/src/Illuminate/Container/Container.php(1222): Illuminate\\Foundation\\Application->make('setQueue')
#5 /Users/thom/Sites/fooProject/vendor/laravel/framework/src/Illuminate/Mail/MailServiceProvider.php(52): Illuminate\\Container\\Container->offsetGet('setQueue')
#6 /Users/thom/Sites/fooProject/vendor/laravel/framework/src/Illuminate/Container/Container.php(776): Illuminate\\Mail\\MailServiceProvider->Illuminate\\Mail\\{closure}(Object(Illuminate\\Foundation\\Application), Array)
#7 /Users/thom/Sites/fooProject/vendor/laravel/framework/src/Illuminate/Container/Container.php(658): Illuminate\\Container\\Container->build(Object(Closure))
#8 /Users/thom/Sites/fooProject/vendor/laravel/framework/src/Illuminate/Container/Container.php(609): Illuminate\\Container\\Container->resolve('mailer', Array)
#9 /Users/thom/Sites/fooProject/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(733): Illuminate\\Container\\Container->make('mailer', Array)
#10 /Users/thom/Sites/fooProject/vendor/laravel/framework/src/Illuminate/Container/Container.php(1222): Illuminate\\Foundation\\Application->make('mailer')
#11 /Users/thom/Sites/fooProject/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(161): Illuminate\\Container\\Container->offsetGet('mailer')
#12 /Users/thom/Sites/fooProject/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(130): Illuminate\\Support\\Facades\\Facade::resolveFacadeInstance('mailer')
#13 /Users/thom/Sites/fooProject/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(217): Illuminate\\Support\\Facades\\Facade::getFacadeRoot()
#14 /Users/thom/Sites/fooProject/app/Observers/FooObserver.php(189): Illuminate\\Support\\Facades\\Facade::__callStatic('to', Array)
#15 /Users/thom/Sites/fooProject/app/Observers/FooObserver.php(132): App\\Observers\\CommentObserver->sendFooEmails(Object(App\\Foo), Object(Illuminate\\Database\\Eloquent\\Collection))

When I use PHP 7.2 instead of PHP 7.3 then, without changing anything else, it works fine and it sends the email without errors.

@driesvints
Copy link
Member

Can you please check #26136 and try some of the things suggested there? Restarting Horizon, PHP-FPM, nginx, queues, etc.

If nothing helps feel free to report back.

@ThomHurks
Copy link
Contributor Author

@driesvints We're running the application and the workers in Kubernetes with Docker containers, so restarting PHP/nginx is not applicable, as we built new images and started those. We're also not using Horizon. I literally only change the base image to PHP 7.2 and redeploy and it works again, so I think you can reopen this?

@driesvints
Copy link
Member

Okay. I'll try to look at this at a later time. I can't seem to figure it out at moment. It's pretty bizare what's going on here.

@driesvints driesvints reopened this Dec 13, 2018
@driesvints driesvints added the bug label Dec 13, 2018
@chris-hud
Copy link

I'm getting the same issue.
Expected behavior in vagrant box running PHP 7.2.5-1. Works in dev server running 7.2. I am migrating to production in a newly created forge server running 7.3 and it fails. To further confuse matters, It worked last night for a time period of 5 minutes when I invited initial users. I cannot get it to work today.

See: https://stackoverflow.com/questions/53002885/laravel-5-7-class-setqueue-does-not-exist

@devcircus
Copy link
Contributor

There's several results from Google for this same issue where the user had issues with 7.3 only but was able to resolve. Seemed to be a config setting in those examples.

@chris-hud
Copy link

chris-hud commented Dec 13, 2018

I have seen those google results where the issue was using QUEUE_DRIVER instead of QUEUE_CONNECTION in env and config. I have QUEUE_CONNECTION set correctly. laravel/framework: "5.7.*",

@chris-hud
Copy link

chris-hud commented Dec 13, 2018

Error on:
Mail::to($user->email)->send(new InviteUser($user));

Mail Class:

namespace App\Mail;

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

class InviteUser extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($user)
    {
        $this->user = $user;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
      return $this->from('test@testwebsite.com')
          ->view('mail.invite')
          ->with(
            [
                  'name' => $this->user->fname . " " . $this->user->lname,
                  'invite_link' => "redacted" . $this->user->invite_token . "/invite",
            ]);
    }
}

.env

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

StackTrace

[2018-12-13 21:09:23] development.ERROR: Class setQueue does not exist {"userId":1,"email":"test@test.com","exception":"[object] (ReflectionException(code: -1): Class setQueue does not exist at /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Container/Container.php:779)
[stacktrace]
#0 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(779): ReflectionClass->__construct('setQueue')
#1 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(658): Illuminate\\Container\\Container->build('setQueue')
#2 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(609): Illuminate\\Container\\Container->resolve('setQueue', Array)
#3 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(735): Illuminate\\Container\\Container->make('setQueue', Array)
#4 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(1222): Illuminate\\Foundation\\Application->make('setQueue')
#5 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Mail/MailServiceProvider.php(52): Illuminate\\Container\\Container->offsetGet('setQueue')
#6 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(776): Illuminate\\Mail\\MailServiceProvider->Illuminate\\Mail\\{closure}(Object(Illuminate\\Foundation\\Application), Array)
#7 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(658): Illuminate\\Container\\Container->build(Object(Closure))
#8 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(609): Illuminate\\Container\\Container->resolve('mailer', Array)
#9 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(735): Illuminate\\Container\\Container->make('mailer', Array)
#10 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Container/Container.php(1222): Illuminate\\Foundation\\Application->make('mailer')
#11 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(161): Illuminate\\Container\\Container->offsetGet('mailer')
#12 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(130): Illuminate\\Support\\Facades\\Facade::resolveFacadeInstance('mailer')
#13 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(217): Illuminate\\Support\\Facades\\Facade::getFacadeRoot()
#14 /home/forge/test.testwebsite.com/app/Http/Controllers/UserController.php(133): Illuminate\\Support\\Facades\\Facade::__callStatic('to', Array)
#15 [internal function]: App\\Http\\Controllers\\UserController->invite(Object(Illuminate\\Http\\Request))
#16 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#17 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('invite', Array)
#18 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\UserController), 'invite')
#19 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Route.php(169): Illuminate\\Routing\\Route->runController()
#20 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(682): Illuminate\\Routing\\Route->run()
#21 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#22 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(43): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#23 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Auth\\Middleware\\Authenticate->handle(Object(Illuminate\\Http\\Request), Object(Closure), 'web')
#24 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#25 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(58): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#26 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Routing\\Middleware\\ThrottleRequests->handle(Object(Illuminate\\Http\\Request), Object(Closure), 60, '1')
#27 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#28 /home/forge/test.testwebsite.com/app/Http/Middleware/CheckLockedUsers.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#29 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): App\\Http\\Middleware\\CheckLockedUsers->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#30 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#31 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#32 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#33 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#34 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(75): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#35 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#36 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#37 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#38 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#39 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#40 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(63): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#41 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#42 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#43 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#44 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#45 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#46 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#47 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#48 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#49 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#50 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(684): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#51 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(659): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#52 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(625): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#53 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(614): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#54 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#55 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#56 /home/forge/test.testwebsite.com/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#57 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#58 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#59 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#60 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#61 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#62 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#63 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#64 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#65 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#66 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#67 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#68 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#69 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#70 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#71 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#72 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#73 /home/forge/test.testwebsite.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#74 /home/forge/test.testwebsite.com/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#75 {main}
"}

@reinink
Copy link
Contributor

reinink commented Dec 15, 2018

I just experienced this as well, and I too use the PHP Redis extension, not predis, so I suspect that's where the issue is.

@hotmeteor
Copy link
Contributor

Same here. I think @reinink is onto it.

@Jam0r85
Copy link

Jam0r85 commented Dec 16, 2018

Using predis here and same issue.

Oddly enough it goes away when I use ShouldQueue.

eg. the following works

class NewRentalStatement extends Notification implements ShouldQueue

however, the following does not.

class NewRentalStatement extends Notification

Proving troublesome as I cannot send password reset links in Nova or Wink.

@Jam0r85
Copy link

Jam0r85 commented Dec 16, 2018

Quick and dirty, commenting out the following in the MailServiceProvider solves the issue.

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

@taylorotwell
Copy link
Member

This error seems really weird. It makes me wonder how could it even be a Laravel bug at all rather than something PHP related. There is no way the $mailer instance in MailServiceProvider can ever be a container instance, which is what the bug seems to imply.

Also adding an interface to the class fixing it makes no sense either.

@taylorotwell
Copy link
Member

I am unable to recreate this with Predis. It will take me a bit longer before I can try it with the Redis PHP extension.

@ThomHurks
Copy link
Contributor Author

I'd have to dive deeper into the code later today, but at quick glance there is a comment that says

 // Once we have create the mailer instance, we will set a container instance
 // on the mailer. This allows us to resolve mailer classes via containers
 // for maximum testability on said classes instead of passing Closures.

Not sure if that's related.

@taylorotwell
Copy link
Member

taylorotwell commented Dec 17, 2018

I was able to recreate it a few times with the redis extension, but after I kept refreshing and hitting the page a few times it went away and I haven't been able to make it happen again.

@taylorotwell
Copy link
Member

Update: I am able to recreate it when I restart PHP-FPM... I can recreate it several times before it goes away again. I'm basically 100% certain this is not a Laravel bug but is some kind of PHP related bug that occurs when the Redis extension is installed.

@driesvints
Copy link
Member

What's everyone's OS here? macOS? Which Linux distro?

@hotmeteor
Copy link
Contributor

Heroku, Heroku-16 stack (Ubuntu 16.04)

@ThomHurks
Copy link
Contributor Author

@taylorotwell Definitely possible it's a PHP bug, as that's the changing variable. What are the next steps then, report it to the PHP project? Haven't dealt with that process myself.

@driesvints I got the bug both on my dev machine (MacOS Mojave) using Valet and on the Docker containers running in Kubernetes (base image Debian Stretch, underlying machines run a Linux distro but I forget which one)

@Jam0r85
Copy link

Jam0r85 commented Dec 17, 2018

MacOS 10.14.1
PHP 7.3.0 (cli) (built: Dec 7 2018 11:00:11)
redis: stable 5.0.3

Everything installed through Brew and upgraded, etc.

@taylorotwell
Copy link
Member

It's a PHP bug of some kind. I can literally add blank lines to the MailServiceProvider and make the bug resolve and mails delivery successfully. There is nothing we can do on our end. It will need to be reported to the PHP team itself. I can make it happen even when my queue driver is set to database and not using Redis at all.

@taylorotwell
Copy link
Member

taylorotwell commented Dec 17, 2018

Disabling Opcache entirely also removes the error. In summary, it seems like when Opcache is enabled on PHP 7.3, it tries to use the $app variable when we are actually attempting to call setQueue on the $mailer variable.

@taylorotwell
Copy link
Member

I have filed a bug report here: https://bugs.php.net/bug.php?id=77310

@fridzema
Copy link
Contributor

I got this when i had installed the beta of telescope, removing it fixed it for me.

@taylorotwell
Copy link
Member

Another way to fix the bug is if we do not use the $app passed to the Closure and instead use $this->app to access the container within that Closure. I could commit that to the framework to fix things on our end but sorta bummer to be working around code that should work because of a weird PHP bug in PHP 7.3.

@taylorotwell
Copy link
Member

I've released 5.7.18 with this "work-around" to use $this->app which resolves the bug on my machine. However, hopefully the PHP team will still look at this as I'm worried it could affect other areas of code too.

@driesvints
Copy link
Member

Gonna leave this open for the time being to follow up.

@judasane
Copy link

In my case it was not about php version, but code:

I had:

$this->payToUser($createdUser, 1000, "Ganaste $1000 por registrarte. Así de fácil es acumular con Kanjea");
\Mail::to($createdUser->email)->send(new \App\Mail\JustRegistered($createdUser));

and the method payToUser:

public function payToUser(User $user, $mount = 1000, string $description)
    {

        Transaction::create([
            'total_ammount' => 0,
            'cash_ammount' => 0,
            'kanjea_ammount' => $mount,
        ]);


//removed from here and the error was gone
$suma = $user->transactionsAsUser->filter(//filtra las transacciones para sumar solo las que tienen valores negativos (kanjes) y las successful
            function ($transaction) {
                return $transaction->status == 'successful' || $transaction->kanjea_ammount < 0;
            }
        )->sum('kanjea_ammount');


        $user->kanjea_balance = $suma;

        $user->save();

    }

When I removed the code after creating transaction It just worked.

By the way, in my local environment (win7+ php7.2.2) never was the error but only using dokku with php 7.3

@judasane
Copy link

In my case it was not about php version, but code:

I had:

$this->payToUser($createdUser, 1000, "Ganaste $1000 por registrarte. Así de fácil es acumular con Kanjea");
\Mail::to($createdUser->email)->send(new \App\Mail\JustRegistered($createdUser));

and the method payToUser:

public function payToUser(User $user, $mount = 1000, string $description)
    {

        Transaction::create([
            'total_ammount' => 0,
            'cash_ammount' => 0,
            'kanjea_ammount' => $mount,
        ]);


//removed_from_here_and_the_error_was gone

$suma = $user->transactionsAsUser->filter(//filtra las transacciones para sumar solo las que tienen valores negativos (kanjes) y las successful
            function ($transaction) {
                return $transaction->status == 'successful' || $transaction->kanjea_ammount < 0;
            }
        )->sum('kanjea_ammount');


        $user->kanjea_balance = $suma;

        $user->save();

    }

When I removed the code after creating transaction It just worked.

By the way, in my local environment (win7+ php7.2.2) never was the error but only using dokku with php 7.3

@GrahamCampbell
Copy link
Member

I think it sounds like this is working with 7.3.1RC1. It's odd that 7.3.1 wasn't released today. I guess it's behind schedule due to new year?

@GrahamCampbell
Copy link
Member

Yes, indeed, the fix is listed in the release notes for the upcoming PHP 7.3.1 release: https://github.com/php/php-src/blob/PHP-7.3.1/NEWS#L39.

@GrahamCampbell GrahamCampbell unpinned this issue Jan 3, 2019
@3alampro
Copy link

3alampro commented Jan 6, 2019

fwiw, I was getting a "Class setEventDispatcher does not exist" on Homebrew PHP 7.3. I disabled OPCache and ran valet restart. Everything is now working as expected.

I'm having the same issue with laravel 5.6 and php 7.3 with OPCache how did you disable it I tried many method without any success I did edit /usr/local/etc/php/7.3/php.ini and did valet restart without any luck

@ThomHurks
Copy link
Contributor Author

@3alampro Please read the thread a little more closely before commenting (others should do this as well, that would be awesome).

TL;DR:

  • Go back to PHP7.2
  • Try again with PHP 7.3.1 when it's released.

@AegirLeet
Copy link
Contributor

FYI: 7.3.1 was just released.

@besthman
Copy link

I am experiencing the same issue. I am using PHP7.3 on Ubuntu 16.04.
I am not sending a mail, I just rendered the Mailable instance

@hotmeteor
Copy link
Contributor

hotmeteor commented Jan 10, 2019

Attention anyone seeking answers to this riddle:

You need PHP 7.3.1.

@besthman
Copy link

Attention anyone seeking answers to this riddle:

You need PHP 7.3.1.

I saw it, it was released today, right?
Cannot find it to install or to get it from the ondrej/php repository yet for Ubuntu

Is there any other way to install the latest PHP for Ubuntu?

Any help is appreciated

@BostjanOb
Copy link

Attention anyone seeking answers to this riddle:
You need PHP 7.3.1.

I saw it, it was released today, right?
Cannot find it to install or to get it from the ondrej/php repository yet for Ubuntu

Is there any other way to install the latest PHP for Ubuntu?

Any help is appreciated

wait a day or two

@besthman
Copy link

Downgraded to php 7.2.13 since I have less time to wait. But will try to upgrade to php7.3.1 when it's released and keep you guys updated. Thx for the help

@satoved
Copy link

satoved commented Jan 10, 2019

Updating to 7.3.1 solved the issue for me.
Don't forget to "brew services restart php@7.3 && valet restart" after "brew upgrade"

@besthman
Copy link

Updating to 7.3.1 solved the issue for me.
Don't forget to "brew services restart php@7.3 && valet restart" after "brew upgrade"

How did you update to 7.3.1? Are you using Linux, Ubuntu?
I am assuming that you're using mac..?

@victordevsquad
Copy link

If using macOs, upgrade php to 7.3.1, by simply running brew upgrade php.

@vicgonvt
Copy link
Contributor

Confirmed, 7.3.1 fixes this issue.

@ThomHurks
Copy link
Contributor Author

Have the people who claim that "7.3.1 fixes it" actually tested with the older version of Laravel? The last few releases include a workaround for this bug, so naturally that will work regardless of the PHP version. The reason I'm asking is because PHP itself claims this bug will only be resolved in version 7.3.2

@GrahamCampbell
Copy link
Member

@ThomHurks Please see the pinned issue: #27052.

@vicgonvt
Copy link
Contributor

@ThomHurks I have a production environment running PHP 7.2.10 and the same code base in local development, and yes, I can confirm that 7.3.0 broke the same codebase locally. Upon upgrading my local to 7.3.1, my test suite is back to green.

@ThomHurks
Copy link
Contributor Author

@GrahamCampbell Hadn't seen that one yet. Thanks!
@vicgonvt What version of Laravel are you running?

@vicgonvt
Copy link
Contributor

@ThomHurks Laravel Framework 5.7.22

@ThomHurks
Copy link
Contributor Author

ThomHurks commented Jan 25, 2019

@vicgonvt That's what I thought, and what I pointed out in my previous comment; that version of Laravel has a workaround for this bug, so you wouldn't be affected by it even if PHP 7.3.1 still had this bug. It should be officially fixed in PHP 7.3.2, according to the bug report Taylor filed on php.net. Some (other) OPCache bugs were fixed in 7.3.1 though.

@vicgonvt
Copy link
Contributor

@ThomHurks AHA!, didn't get that the first round of messages. So I guess the workaround is only valid for 7.3.1, because I was getting errors running 7.3.0.

@ThomHurks
Copy link
Contributor Author

@vicgonvt The workaround should be valid for 7.3.0 too, but be aware that 7.3.0 had a lot more issues than just this bug. I've decided for my own projects to wait a few patch releases before I attempt another go at PHP 7.3 for this reason.

@vicgonvt
Copy link
Contributor

@ThomHurks I was unable to get passed that setQueue error just yesterday on 7.3.0 and still on 5.7.22. There is definitely something going on there with that. But you are right, we are keeping our production environment locked to 7.2.*. I mostly upgraded my local environment to play with the new PHP features, not really intending to deploy that change to production.

@ThomHurks
Copy link
Contributor Author

@vicgonvt Ouch, that sounds like the workaround that was added to Laravel doesn't actually work around the problem then. I'll see if I can do some testing tomorrow with my own setup.

@driesvints
Copy link
Member

Please wait with upgrading if you need this until PHP 7.3.2 has been released.

@laravel laravel locked and limited conversation to collaborators Jan 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests