Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix jsonRequest inAbstractBrowser for GET methods#39281

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@alexander-schranz
Copy link
Contributor

@alexander-schranzalexander-schranz commentedDec 2, 2020
edited by nicolas-grekas
Loading

QA
Branch?5.x
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix #...
LicenseMIT
Doc PRsymfony/symfony-docs#...

When implementing#38596 I was not aware of that $parameters are also used as queryParameters and are converted based on the Methodhere into query or request data. This I think should be handled the same way for the jsonRequest also instead of just unset the server variables we should to reset to the predefined server variables.

@alexander-schranzalexander-schranzforce-pushed thebugfix/abstract-browser-json-request branch 3 times, most recently fromcc1747f to4d90a87CompareDecember 2, 2020 09:59
@alexander-schranzalexander-schranzforce-pushed thebugfix/abstract-browser-json-request branch from4d90a87 to589d06fCompareDecember 2, 2020 10:07
@alexander-schranzalexander-schranz changed the titleFix jsonRequest in AbstractBrowser for GET Methods[BrowserKit] Fix jsonRequest in AbstractBrowser for GET MethodsDec 2, 2020
@nicolas-grekasnicolas-grekas added this to the5.x milestoneDec 23, 2020
@alexander-schranz
Copy link
ContributorAuthor

@nicolas-grekas anything missing here from my side?

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

(failures are false-positives)

break;
default:
$content =null;
$query =$parameters;
Copy link
Member

@nicolas-grekasnicolas-grekasJan 26, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

wait, I'm not sure anymore that this makes sense:$parameters doesn't go through the processing ofjson_encode().
That means objects (that do or don't implementJsonSerializable) are going to be passed differently when usingGET vs other verbs.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah based on the method we set it a request body or not. This is based on the linked logic which symfony currently use here:https://github.com/symfony/symfony/blob/v5.2.0/src/Symfony/Component/HttpFoundation/Request.php#L388-L404
It does not make sense to convert query parameters to JSON as nobody will converted it back. Which is in the FosRestBundle and ApiPlatform converted into the$request->request attributes by theBodyListener.

@alexander-schranz
Copy link
ContributorAuthor

alexander-schranz commentedApr 26, 2021
edited
Loading

@nicolas-grekas any update to this I think this still should match the same logic as the http foundationRequest object, we are using this in@sulu and without this change it was really buggy and not usable in all cases with GET.

@OskarStarkOskarStark changed the title[BrowserKit] Fix jsonRequest in AbstractBrowser for GET Methods[BrowserKit] Fix jsonRequest inAbstractBrowser for GET methodsAug 4, 2021
@fabpotfabpot modified the milestones:5.4,6.1Nov 16, 2021
@alexander-schranz
Copy link
ContributorAuthor

@nicolas-grekas I still think this change is valid because of:

switch (strtoupper($method)) {
case'POST':
case'PUT':
case'DELETE':
if (!isset($server['CONTENT_TYPE'])) {
$server['CONTENT_TYPE'] ='application/x-www-form-urlencoded';
}
// no break
case'PATCH':
$request =$parameters;
$query = [];
break;
default:
$request = [];
$query =$parameters;
break;
}

And because of GET, HEAD, OPTION parameters are query strings and the content has no meaning:https://stackoverflow.com/questions/978061/http-get-with-request-body

But think this will not being merged as it is now open a long time?

@fabpotfabpot modified the milestones:6.1,6.2May 20, 2022
@nicolas-grekasnicolas-grekas modified the milestones:6.2,6.3Nov 5, 2022
@carsonbotcarsonbot changed the title[BrowserKit] Fix jsonRequest inAbstractBrowser for GET methodsFix jsonRequest inAbstractBrowser for GET methodsFeb 16, 2023
@nicolas-grekas
Copy link
Member

I think nobody understands the change :)
Also, GET with body can exist, eg with Elasticsearch
I'm closing because this didn't get traction and it's always possible to use another method for GET when you want that behavior I suppose.

maxhelias reacted with confused emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas requested changes

+1 more reviewer

@maxheliasmaxheliasmaxhelias approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

6.3

Development

Successfully merging this pull request may close these issues.

5 participants

@alexander-schranz@nicolas-grekas@maxhelias@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp