[8.x] Fix replacing request options #40954
Merged
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 is an attempt at fixing #40952. Right now, when using
array_merge_recursive
, options which already exist will be merged into a new array. See the behavior here: https://3v4l.org/joqh9It seems to be this is always unwanted as you'd simply want to replace the previous option that was present. I've added a test for the new behavior. As you can see it verifies the originally set option of
http_errors
stays set properly and doesn't gets converted to an array.This issue was uncovered in Laravel 9 where we now set the default
connect_timeout
. Apps that were overriding this withwithOptions
saw their apps and integrations break becauseconnect_timeout
was suddenly an array instead of an integer.I sent this in to 8.x because Laravel 8 also suffers from this. I have to admit that I don't know of any situation where the behavior is wanted but that couldn't mean it's not used. Therefor I'm not 100% if this will break anything. But the current behavior definitely isn't the correct one either.
After merging this this will need to be merged into 9.x as well by merging the 8.x branch into the 9.x branch.
Fixes #40952