framework icon indicating copy to clipboard operation
framework copied to clipboard

[10.x] Create new Json ParameterBag Instance when cloning Request

Open kohlerdominik opened this issue 3 years ago • 0 comments

When creating a new Request instance by createFrom, all attributes of the request get copied to a new InputBag-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 of Illuminate\Foundation\Http\FormRequest. They should consistenly either use Illuminate\Http\Request (which is a singleton), or pass the same instance of Illuminate\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.

kohlerdominik avatar Dec 02 '22 10:12 kohlerdominik