[10.x] Create new Json ParameterBag Instance when cloning Request #45164
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.
When creating a new Request instance by
createFrom
, all attributes of the request get copied to a newInputBag
-instance (Request:444-450)The only exception is the
$json
-attribute: there, the object of the old instance ($from
) get referenced. This means, if the ParameterBag is modified in the new instance, this change also applies in the old instance. I do not think, that this behavior is intended. For me, it was certainly unexpected.This PR would fix this issue quite straight forward by simply cloning the ParameterBag instance. If another type of implementation is desired to fix this, please let me know.
This issue was merged already in 9.x in #44671. In #44812 we realized, that this is a breaking change, therefore it was reverted.
I suggest to release this change with the next major, and having a note about the change the upgrade guide.
Applications, that break because of this change are mixing instances of
Illuminate\Http\Request
with others ofIlluminate\Foundation\Http\FormRequest
. They should consistenly either useIlluminate\Http\Request
(which is a singleton), or pass the same instance ofIlluminate\Foundation\Http\FormRequest
forward. See detailed explaination with examples here. It's important to point out, that they are not desigend to be mixed. Because of the bug, it was possible to mix them and use parameters from the$json
-ParameterBag within each other. It didn't work for other ParameterBags.