Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] refactor(queue): update getConfig to handle empty and "default" connection names #51506

Closed
wants to merge 1 commit into from

Conversation

victorelec14
Copy link

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:
image

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:

php artisan queue:work redis
php artisan queue:work null
php artisan queue:work "null"
php artisan queue:work ""

The method now supports these parameters:

php artisan queue:work default
php artisan queue:work "default"
php artisan queue:work " "  (1 space)
php artisan queue:work "    " ( x spaces)

Docs : https://laravel.com/docs/11.x/queues#specifying-the-connection-queue

Thanks

…ames

Updated the getConfig() method to properly handle cases where the connection name is empty, consists of only whitespace, or is 'default'. This ensures that the fallback to the 'null' driver is correctly applied in these scenarios.
@victorelec14 victorelec14 changed the title refactor(queue): update getConfig to handle empty and "default" connection names [11.x] refactor(queue): update getConfig to handle empty and "default" connection names May 19, 2024
@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions!

If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants