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 · 63 comments

Comments

Projects
None yet
@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

This comment has been minimized.

Copy link
Member

driesvints commented Dec 13, 2018

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.

@driesvints driesvints closed this Dec 13, 2018

@ThomHurks

This comment has been minimized.

Copy link
Contributor

ThomHurks commented Dec 13, 2018

@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

This comment has been minimized.

Copy link
Member

driesvints commented Dec 13, 2018

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

This comment has been minimized.

Copy link

chris-hud commented Dec 13, 2018

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

This comment has been minimized.

Copy link
Contributor

devcircus commented Dec 13, 2018

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor

hotmeteor commented Dec 16, 2018

Same here. I think @reinink is onto it.

@Jam0r85

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

taylorotwell commented Dec 17, 2018

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

This comment has been minimized.

Copy link
Member

taylorotwell commented Dec 17, 2018

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

This comment has been minimized.

Copy link
Contributor

ThomHurks commented Dec 17, 2018

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

taylorotwell commented Dec 17, 2018

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

This comment has been minimized.

Copy link
Member

driesvints commented Dec 17, 2018

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

@hotmeteor

This comment has been minimized.

Copy link
Contributor

hotmeteor commented Dec 17, 2018

Heroku, Heroku-16 stack (Ubuntu 16.04)

@ThomHurks

This comment has been minimized.

Copy link
Contributor

ThomHurks commented Dec 17, 2018

@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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

taylorotwell commented Dec 17, 2018

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

taylorotwell commented Dec 17, 2018

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

@fridzema

This comment has been minimized.

Copy link

fridzema commented Dec 17, 2018

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

@taylorotwell

This comment has been minimized.

Copy link
Member

taylorotwell commented Dec 17, 2018

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

This comment has been minimized.

Copy link
Member

taylorotwell commented Dec 17, 2018

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

This comment has been minimized.

Copy link
Member

driesvints commented Dec 17, 2018

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

@andru-h

This comment has been minimized.

Copy link

andru-h commented Dec 20, 2018

@driesvints I saw that Taylor found a work around for that PHP issue and was going to released it with the next version of Laravel. Actually he released it in Laravel 5.7.18. I am currently working with PHP 7.3 and Laravel 5.7.19 and everything is going well. Thanks to that we don't have to wait for PHP to solve their issue 👍

@driesvints

This comment has been minimized.

Copy link
Member

driesvints commented Dec 20, 2018

@andru-h gotcha

@fridzema

This comment has been minimized.

Copy link

fridzema commented Dec 20, 2018

For me the issue was already there in november:
laravel/telescope#190

@hotmeteor

This comment has been minimized.

Copy link
Contributor

hotmeteor commented Dec 20, 2018

@fridzema ... were you on 7.3 in November?

@fridzema

This comment has been minimized.

Copy link

fridzema commented Dec 20, 2018

@hotmeteor i can't say with confidence yes or no, but for me removing telescope was the fix at the moment. Maybe there happened some opcache busting what it actually solved. Didn't investigate further at the time.

@rodrigopedra

This comment has been minimized.

Copy link
Contributor

rodrigopedra commented Dec 20, 2018

Now that @fridzema mentioned telescope, I remember that when I got that error where I ended syncing my files with the laravel/laravel repo, one other thing I did was to remove telescope.

I got the error in projects with telescope installed but not in projects without it.

Currently all my forge servers and projects in production (4 servers and 5 projects) are upgraded to PHP 7.3 with opcache enabled and I am not having these errors anymore. I also use the php-redis extension instead of predis.

If it is of any help, Taylor or someone from Laravel Forge team can look at my forge setup. But there is nothing fancy in any of them.

@vimalmistry

This comment has been minimized.

Copy link

vimalmistry commented Dec 20, 2018

Same issue is here. I downgraded to php 7.2 and now is working fine.

@andru-h

This comment has been minimized.

Copy link

andru-h commented Dec 20, 2018

@vimalmistry try upgrading to PHP 7.3 and Laravel to the latest version, it should be solved by now.

@markdegrootnl

This comment has been minimized.

Copy link

markdegrootnl commented Dec 20, 2018

I can confirm disabling OPcache on PHP 7.3 resolves this for now.

@ThomHurks

This comment has been minimized.

Copy link
Contributor

ThomHurks commented Dec 20, 2018

There's a possible fix (not confirmed yet) in 7.3.1RC1

@more-yogesh

This comment has been minimized.

Copy link

more-yogesh commented Dec 21, 2018

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

MacBook Pro

@more-yogesh

This comment has been minimized.

Copy link

more-yogesh commented Dec 21, 2018

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

@hassanazimi

This comment has been minimized.

Copy link

hassanazimi commented Dec 23, 2018

fixed here. no longer seeing this.

@judasane

This comment has been minimized.

Copy link

judasane commented Dec 27, 2018

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

This comment has been minimized.

Copy link

judasane commented Dec 27, 2018

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

This comment has been minimized.

Copy link
Member

GrahamCampbell commented Jan 3, 2019

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

This comment has been minimized.

Copy link
Member

GrahamCampbell commented Jan 3, 2019

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor

ThomHurks commented Jan 6, 2019

@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

This comment has been minimized.

Copy link

AegirLeet commented Jan 10, 2019

@besthman

This comment has been minimized.

Copy link

besthman commented Jan 10, 2019

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

This comment has been minimized.

Copy link
Contributor

hotmeteor commented Jan 10, 2019

Attention anyone seeking answers to this riddle:

You need PHP 7.3.1.

@besthman

This comment has been minimized.

Copy link

besthman commented Jan 10, 2019

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

This comment has been minimized.

Copy link

BostjanOb commented Jan 10, 2019

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

This comment has been minimized.

Copy link

besthman commented Jan 10, 2019

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

This comment has been minimized.

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

This comment has been minimized.

Copy link

besthman 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"

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

@victordevsquad

This comment has been minimized.

Copy link

victordevsquad commented Jan 17, 2019

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

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