Lumen-framework: url() helper generates wrong URLs when queue is used

Created on 9 Jul 2018  路  2Comments  路  Source: laravel/lumen-framework

  • Lumen Version: 5.6.4
  • PHP Version: 7.2
  • Database Driver & Version: MySQL 5.7

Description:

I'm using Mail Notifications. When I set QUEUE_DRIVER=sync in my .env file everything is OK:

image

But if I change the queue driver to database and run php artisan queue:work I receive a wrong URL:

image

The problem may be related to this issue: https://github.com/laravel/framework/issues/14139

Steps To Reproduce:

.env

APP_URL=http://mysite.local
QUEUE_DRIVER=database

config/app.php

<?php

return [
    'name' => env('APP_NAME', 'Lumen'),
    'url' => env('APP_URL', 'http://localhost'),
];

app/Notifications/UserCreated.php

...

public function toMail($notifiable)
{
    return (new MailMessage)
                ->subject('Confirm your email address')
                ->line('Please, confirm your email address by clicking the button below:')
                ->action('Confirm email', url('confirm?token=' . $notifiable->verification_token))
                ->line('Thank you for using our application!');
}

...

Most helpful comment

Seems like this was fixed now. Thanks!

All 2 comments

The fix, you referenced in the issue, is implemented in Lumen. You can find it in the setRequestForConsole method on line 70 in Laravel\Lumen\Console\Kernel.

However, in the constructor of the same class, a conditional is defined which checks whether the Request has already been bound in the container. If this is the case, the setRequestForConsole will be called.

In the Application class, located in the Lumen framework, the request method will be bound on every request, no matter if you're running in the console or not. That's why the setRequestForConsole method will never get called.

Seems like this was fixed now. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timrogers picture timrogers  路  3Comments

rtheunissen picture rtheunissen  路  3Comments

Andrei-Vakulski picture Andrei-Vakulski  路  3Comments

zhengyuhe123 picture zhengyuhe123  路  4Comments

rmblstrp picture rmblstrp  路  5Comments