[9.x] Ensure subsiquent calls to Mailable->to() overwrite previous entries#45885
Conversation
|
Can you explain how the reversing fixes the issue? |
|
So, when adding additional addresses via Before this change, calling the following: $mailable->to("taylor@laravel.com")->to("taylor@laravel.com", "Taylor Otwell")Will result in the following to array: [
["email"=>"taylor@laravel.com", "name"=>null]
]Whereas intuitively, the name should be overridden by the last provided instance. Eg: [
["email"=>"taylor@laravel.com", "name"=>"Taylor Otwell"]
]In place of a Frustratingly, this caught us out when updating from an older version as |
|
Awesome! Thanks for merging 🙌 |
Fixes a bug introduced by #45119 where subsequent calls to
->to()with a different name will not take effect.We do this by reversing the collection before the call to
uniqueand then reversing it back.A test for this functionality has been added to
MailMailableTest::testMailableSetsRecipientsCorrectly()More context - #45119 (comment)