Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request Merge Problem #47877

Closed
kursadaltanmed opened this issue Jul 28, 2023 · 6 comments · Fixed by #47914
Closed

Request Merge Problem #47877

kursadaltanmed opened this issue Jul 28, 2023 · 6 comments · Fixed by #47914
Assignees

Comments

@kursadaltanmed
Copy link

kursadaltanmed commented Jul 28, 2023

Laravel Version

9.52.12

PHP Version

8.0.2

Database Driver & Version

Mysql

Description

The request merge function we use in Middleware does not work in this version. It does not merge into the request.

9.52.11 version don't have this problem.

Steps To Reproduce

Ex:

SomeMiddleware
$request->merge(['fullname' => concate($request->get('name') ?? "", $request->get('lastname') ?? "")]);

Body

Content Type : Json

{
"name" : "Test",
"lastname" : "Test",
}

@taylorotwell
Copy link
Member

What kind of value are you attempting to merge in?

We had to make changes to the request input due to type changes in Symfony and they have classes marked as final so we have no way to work around it.

@ImJustToNy
Copy link
Contributor

ImJustToNy commented Jul 29, 2023

I experience similar issue in laravel v9.52.12 / php v8.1.21. Also json endpoint.

@kursadaltanmed
Copy link
Author

I have two string input parameters. I concatenate these two strings into a variable, and then I try to merge that variable into the request. It used to work without any issues in older versions, but in the current version, I'm unable to add the concatenated variable to the request.

I want to clarify that I'm using middleware for this code block:

$request->merge(['fullname' => concat($request->get('name') ?? "", $request->get('lastname') ?? "")]);

Both 'name' and 'lastname' are expected to be in string format in the JSON request.

@manish-pareek
Copy link

Yes same problem for me as well . @taylorotwell @kursadaltanmed

    $request->merge(['country' => 'india']);
    dd($request->country);    //Working
    dd($request->get('country'));  //Not-working..  It was working earlier



    $request->request->add(['country' => 'india']);
    dd($request->country);    //Not Working...  It was working earlier 
    dd($request->get('country'));  //working

@taylorotwell
Copy link
Member

I would stop using $request->get. We never document that method anywhere. It is an internal Symfony method.

@timacdonald
Copy link
Member

I've created a potential PR to fix this issue: #47914

I'll close this and we can track the issue in the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants