Skip to content

Commit

Permalink
fix breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 28, 2022
1 parent 9435827 commit 56d433a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Illuminate/Queue/QueueServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ protected function registerFailedJobServices()
$this->app->singleton('queue.failer', function ($app) {
$config = $app['config']['queue.failed'];

if (! isset($config['driver']) || $config['driver'] === 'null') {
if (array_key_exists('driver', $config) &&
(is_null($config['driver']) || $config['driver'] === 'null')) {
return new NullFailedJobProvider;
}

Expand Down

1 comment on commit 56d433a

@mfn
Copy link
Contributor

@mfn mfn commented on 56d433a Feb 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caused a small issue in our case, because (years ago) we did the mistake and completely commented out the 'failed' block in config/queue.php (instead of trying specify a null driver, which I think until this change or 9435827 didn't work ?):

    /*
     * Disabled, we're not using it: if you enable it, test it's working
     * otherwise exceptions when saving the failed job will shadow
     * the actual exception why the job failed in the first place.
     *
    'failed' => [
        'driver' => env('QUEUE_FAILED_DRIVER', 'database'),
        'database' => env('DB_CONNECTION', 'mysql'),
        'table' => 'failed_jobs',
    ],
    */

When a job failed, it caused this exception (which kind of shadowed the original error why the job failed):

PHP Warning: array_key_exists() expects parameter 2 to be array, null given in/vendor/laravel/framework/src/Illuminate/Queue/QueueServiceProvider.php on line 239

It's not a big deal, fix is easy with this code change:

  • comment in the 'failed' part
  • set the 'driver' to 'null'
  • 🎉

cheers!

Please sign in to comment.