Description
- Laravel-mongodb Version: 3.8
- PHP Version: 8.0
Description:
In MongodbQueueServiceProvider
there is a check done for the config queue.failed.database
which then connects to the Mongo DB if true.
$this->app['db']->connection(config('queue.failed.database'))->getDriverName() == 'mongodb'
However it is possible to disable the failed log storage whilst still having a value in the queue.failed.database
config.
You may instruct Laravel to discard failed jobs without storing them by setting the queue.failed.driver configuration option's value to null. Typically, this may be accomplished via the QUEUE_FAILED_DRIVER environment variable:
QUEUE_FAILED_DRIVER=null
In these cases, since you're only checking the queue.failed.database
config it will still attempt to connect.
Steps to reproduce
I can't produce specific steps that cause a bug since my exact circumstances are unusual, but it should be obvious that a check should be done if the failed log storage is disaled.
You can verify what i'm saying via the following:
- Edit
config/queue.php
in a Laravel to application to the following
//'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'driver' => null,
'database' => env('DB_CONNECTION', 'mysql'),
- Edit
\Jenssegers\Mongodb\Connection
to
public function __construct(array $config)
{
dd(debug_backtrace());
-
Run the app and note that it is being called from
mongodb/src/MongodbQueueServiceProvider.php:16
in the 4th Backtrace. -
Edit
config/database.php
again
//'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'driver' => null,
//'database' => env('DB_CONNECTION', 'mysql'),
'database' => null,
- Run the app and note that this time MongoDB is not being called at all, or being called from a Database Provider rather than a Queue Provider.
Expected behaviour
The Queue Provider should not connect to Mongo DB if Failed Log Storage is disabled.