-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Missing Data Handling (checkbox edge cases) #45081
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
base: 7.4
Are you sure you want to change the base?
[Form] Missing Data Handling (checkbox edge cases) #45081
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as outdated.
This comment was marked as outdated.
bb97fdb
to
adb9016
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay reviewing this, it's definitely interesting!
I force-pushed on your fork to turn the trait into a class. Please fetch + reset --hard before reopening the branch. There are some tests failing that need to be addressed.
I'm just wondering if this shouldn't go on 6.2: yes, this can be seen as a bug fix, but it's also a new behavior to me.
/cc @symfony/mergers WDYT?
Agree for 6.2 |
Tests for php >=8.1 are all green. |
Great thanks. OK to rebase+retarget for 6.2? |
d939f4f
to
ecce817
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks!
the test failures look related |
return $data; | ||
} | ||
} | ||
} catch (\Error $error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catching type errors here doesn't look like the right solution to me. We should investigate instead why the $type
property in FormConfigBuilder
isn't initialized at this point and fix that root issue instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like it either.
Another solution could be to make FormConfigBuilderInterface::getType() nullable. Then null state would have to be handled in these methods where getType() is called:
ValidatorDataCollector#getCasters
FormDataExtractor#extractConfiguration
FormDataCollector#getCasters
FormTypeCsrfExtension#finishView
FormTypeCsrfExtension#buildForm
BaseType#buildView
Button#createView
I don't know if null/undefined type is a valid case or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can look into why we run into this error here. But that will probably not happen before the weekend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Status: needs work |
Can you please rebase @filiplikavcan? |
src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php
Outdated
Show resolved
Hide resolved
A form that consists of unchecked checkboxes only will not be recognized as being submitted with the standard If yes, you might want to mention #20210 in the list of tickets as well. Update: I have been looking at this code for over 10 minutes now and I am unable to figure out how it would be able to tell whether we're |
$missingData = $this->missingDataHandler->missingData; | ||
|
||
if ($missingData === $data = $this->missingDataHandler->handle($form, $request->query->all()[$name] ?? $missingData)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot follow this code and would love if we could break this down into smaller chunks, maybe using expressive variable names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Is it easier to follow?
symfony/src/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php
Lines 60 to 69 in 4dcd5a4
$missingData = $this->missingDataHandler->missingData; | |
$queryData = $request->query->all()[$name] ?? $missingData; | |
$data = $this->missingDataHandler->handle($form, $queryData); | |
if ($missingData === $data) { | |
// Don't submit GET requests if the form's name does not exist | |
// in the request | |
return; | |
} |
…equestHandler when handling GET requests)
5aad0a4
to
4dcd5a4
Compare
I think it would not be possible to tell the two situations apart. Look at this test: symfony/src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php Lines 134 to 145 in 4dcd5a4
|
Uh oh!
There was an error while loading. Please reload this page.