[12.x] Fix: Correctly fallback to notification's connection/queue when using viaConnections/viaQueues #57625
+105
−4
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.
The Problem:
When a
ShouldQueuenotification is dispatched:viaQueues()orviaConnections()methods, all channels correctly utilize the notification's own$connectionand$queueproperties (e.g.,'redis'and'admin_notifications') as their queue/connection settings.viaQueues()orviaConnections()to customize settings for only some channels, the channels that are not customized incorrectly bypass the notification's own default properties and fall back directly to the application's global default queue/connection settings.Example Scenario:
QUEUE_CONNECTION=sync, Default Queue:base_queue$connection = 'redis',$queue = 'admin_notifications'mailchannel: Usessqsconnection,mail_urgentqueue. (Correct)databasechannel: Uses thedatabaseconnection (Global Default) and thebase_queuequeue (Global Default). (INCORRECT) It should have used the notification's defaults (redis/admin_notifications).The Fix:
This PR modifies the queue resolution logic. For channels not explicitly defined in
viaQueues()orviaConnections(), Laravel will now first check and use the notification's own$queueor$connectionproperties. It will only fallback to the application's global defaults if the notification's properties are also unset.mailchannel: Usesredisconnection,mail_urgentqueue. (Correct)databasechannel: Uses theredisconnection (Notification Default) and theadmin_notificationsqueue (Notification Default). (CORRECT)