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

[HttpFoundation] Use InputBag for POST requests too#40315

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

Merged
fabpot merged 1 commit intosymfony:5.xfromacasademont:use_input_bag
Mar 12, 2021

Conversation

@acasademont
Copy link
Contributor

@acasademontacasademont commentedFeb 26, 2021
edited
Loading

QA
Branch?5.x
Bug fix?no
New feature?no
Deprecations?no
TicketsPartially revert#37265
LicenseMIT
Doc PR-

#37265 was created as a fix for#37100. However, when#37327 was merged, the original bug was also fixed with a different solution (allowing null values onInputBag::set) and parts of#37265 are not needed anymore. By using onlyInputBag as the$request bag we can tighten the typehint again and make static analysis a bit more useful.

ro0NL reacted with thumbs up emojidvdknaap reacted with thumbs down emoji
@acasademont
Copy link
ContributorAuthor

PS: Also not sure if this should be considered a bugfix and merged into 5.2.x instead of 5.x

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedFeb 26, 2021
edited
Loading

Thinking a bit more about this, there might still be an issue when using JSON payloads: theInputBag::get() returns onlystring|null. That means booleans, integers, floats found in JSONs will be lost.

@nicolas-grekasnicolas-grekas added this to the5.x milestoneFeb 26, 2021
@acasademont
Copy link
ContributorAuthor

acasademont commentedFeb 26, 2021
edited
Loading

@nicolas-grekas that's only because of the phpdoc typehint, there's nothing preventing anint|bool|float from being returned. Maybe the typehint of InputBag should bestring|int|bool|float|null?

@nicolas-grekas
Copy link
Member

Can you update the type hints so that we can discuss the full change that would be needed?

@nicolas-grekas
Copy link
Member

(and add related tests btw)

@acasademont
Copy link
ContributorAuthor

Added the missing scalar type hints and some testing

$this->assertNull($bag->get('null','default'),'->get() returns null if null is set');
$this->assertSame(1,$bag->get('int'),'->get() gets the value of an int parameter');
$this->assertSame(1.0,$bag->get('float'),'->get() gets the value of a float parameter');
$this->assertFalse($bag->get('bool'),'->get() gets the value of a bool parameter');
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps assert eg. $default=true is never casted to string

acasademont reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Sure, sorry I didn't see your comment!

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.

LGTM thanks.
@ro0NL's suggestion is a good one, can you update the PR if you agree?

@fabpot
Copy link
Member

Thank you@acasademont.

@fabpotfabpot merged commit7754bed intosymfony:5.xMar 12, 2021
@acasademontacasademont deleted the use_input_bag branchMarch 12, 2021 09:17
@acasademont
Copy link
ContributorAuthor

Ah! Thx@fabpot ! I was planning to update the tests this weekend, I'll submit another PR for them.

@dvdknaap
Copy link

dvdknaap commentedJun 11, 2021
edited
Loading

Why are arrays not allowed anymore ?

This means if you got an form with checkboxes it's not allowed anymore.

Edit:@acasademont@fabpot Why is the set accepting arrays but the get not could this be fixed asap please?

@olsavmic
Copy link
Contributor

olsavmic commentedJul 8, 2021
edited
Loading

Why are arrays not allowed anymore ?

This means if you got an form with checkboxes it's not allowed anymore.

Edit:@acasademont@fabpot Why is the set accepting arrays but the get not could this be fixed asap please?

I guess you're supposed to access those nested arrays by calling$inputBag->all('key'). It's slightly misleading though now, I also stumbled upon this.
See:#41766

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

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

+1 more reviewer

@ro0NLro0NLro0NL left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

7 participants

@acasademont@nicolas-grekas@fabpot@dvdknaap@olsavmic@ro0NL@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp