Fix EmailTask named-parameter error for associative address arrays#472
Merged
dereuromark merged 2 commits intomasterfrom Apr 17, 2026
Merged
Fix EmailTask named-parameter error for associative address arrays#472dereuromark merged 2 commits intomasterfrom
dereuromark merged 2 commits intomasterfrom
Conversation
PHP 8 treats string keys in the argument array of call_user_func_array() as named parameters, so queued payloads with an associative email => name map for to/from/cc/bcc/replyTo would fail with 'Unknown named parameter'. Route address setters through a helper that unpacks list-shaped values positionally (preserving the prior behavior) and forwards associative maps as a single positional argument.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #472 +/- ##
============================================
+ Coverage 77.08% 77.15% +0.07%
- Complexity 938 944 +6
============================================
Files 45 45
Lines 3172 3182 +10
============================================
+ Hits 2445 2455 +10
Misses 727 727 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #471.
EmailTask::run()expanded every mailer setting throughcall_user_func_array(). Under PHP 8+, string keys in the argument array are interpreted as named parameters, so queued payloads using CakePHP's associative address-map format:...failed with
Unknown named parameter $recipient@example.comagainstsetTo()/setFrom()/etc.Fix
Address setters (
to,from,cc,bcc,replyTo, plussender/returnPath) are now handled explicitly before the generic settings loop, consistent with howtheme/template/attachmentswere already special-cased.A small
addressArguments()helper normalizes the value:['email', 'Name']or legacy wrapped[['email' => 'Name']]) are unpacked positionally — matching the previous behavior,email => namemaps, is forwarded as a single positional argument so PHP's named-parameter semantics never kick in.All previously working payload formats continue to work unchanged; the associative map format now also works, matching what
Cake\Mailer\Mailer::setTo()natively accepts.A regression test covers
to,from,cc,bcc, andreplyTowith associative address maps.