Description
PHP Version
8.2.0
CodeIgniter4 Version
4.6.0
Queue Package Version
dev:develop
Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Queue Driver
database
Queue Configuration
<?php
declare(strict_types=1);
/**
* This file is part of CodeIgniter Queue.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Datamweb\DadAfza\Config;
use CodeIgniter\Queue\Config\Queue as BaseQueue;
use CodeIgniter\Queue\Exceptions\QueueException;
use CodeIgniter\Queue\Handlers\DatabaseHandler;
use CodeIgniter\Queue\Handlers\PredisHandler;
use CodeIgniter\Queue\Handlers\RedisHandler;
use CodeIgniter\Queue\Interfaces\JobInterface;
use CodeIgniter\Queue\Interfaces\QueueInterface;
class Queue extends BaseQueue
{
/**
* Database handler config.
*/
public array $database = [
'dbGroup' => 'default',
'getShared' => true,
// use skip locked feature to maintain concurrency calls
// this is not relevant for the SQLite3 database driver
'skipLocked' => false,
];
/**
* Default priorities for the queue
* if different from the "default".
*/
public array $queueDefaultPriority = [
'notify' => 'high',
];
/**
* Valid priorities in the order for the queue,
* if different from the "default".
*/
public array $queuePriorities = [
'notify' => ['high'],
];
/**
* Your jobs handlers.
*
* @var array<string, class-string<JobInterface>>
*/
public array $jobHandlers = [
'low_stock' => \Datamweb\DadAfza\Jobs\LowStockNotification::class,
];
}
What happened?
When using the following code:
service('queue', config('Datamweb\DadAfza\Config\Queue'), false)->push('notify', 'low_stock', ['text' => $text]);
I expect everything to work properly, with the configuration data, including the $jobHandlers defined in the file config('Datamweb\DadAfza\Config\Queue'), being executed without issues. However, currently, this is not the case, and I encounter an error.
Steps to Reproduce
Define a custom queue configuration in Datamweb\DadAfza\Config\Queue
.
Use the following code to push a job to the queue:
service('queue', config('Datamweb\DadAfza\Config\Queue'), false)->push('notify', 'low_stock', ['text' => $text]);
Observe that the job fails with an error indicating the job handler is not defined in $jobHandlers.
Expected Output
When passing a custom configuration file, such as config('Datamweb\DadAfza\Config\Queue')
, I expect the queue service to use this configuration correctly, including all the job handlers ($jobHandlers) defined in it. This should work without issues, and the job 'notify' should be processed correctly according to the handlers specified in the custom configuration.
Anything else?
Instead of using the provided custom configuration, the service falls back to the default configuration, causing the job handlers and other settings to be ignored. This results in the error message indicating that the job name 'notify' is not found in the $jobHandlers array.