[11.x] refactor(queue): update getConfig to handle empty and "default" connection names #51506
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates the getConfig() method in the queue configuration class to better handle edge cases when retrieving the connection configuration. The updated method now accounts for cases where the connection name is empty, consists only of whitespace, or is set to 'default' (as text).
This change is made to make some queues scripts more flexible by accepting the connection name as "default." Additionally, if the connection name is empty, it will use the default connection from Queue.php.
I find it confusing that the command cannot use the connection name "default."
php artisan queue:work default php artisan queue:work "default"
Result:
Possible Breaking Change
If there is a connection named "default," Laravel will use the config from queue.connections.default instead of the connection defined with the name "default." Therefore, it might be better to only allow empty spaces and not the name "default."
To be decided: whether "default" will be allowed as a parameter to use the queue.connections.default.
Any changes or suggestions are welcome. :)
Before the method supported already these connection names:
The method now supports these parameters:
Docs : https://laravel.com/docs/11.x/queues#specifying-the-connection-queue
Thanks