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

[Form] Fix form value merging involving file upload, collection & checkbox#54324

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

Open
priyadi wants to merge13 commits intosymfony:5.4
base:5.4
Choose a base branch
Loading
frompriyadi:dev-fix-merge-options-form

Conversation

priyadi
Copy link
Contributor

@priyadipriyadi commentedMar 18, 2024
edited
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
IssuesFix#53359
LicenseMIT

This is an update to the PR#53353

This fixes another value-files merging bug involving collections of a form containing a file upload field and a checkbox.

maidmaid and ZHB reacted with thumbs up emoji
@priyadi
Copy link
ContributorAuthor

paging@nicolas-grekas

@@ -30,8 +30,6 @@ private function __construct()
* a form and needs to be consistent. PHP keyword `empty` cannot
* be used as it also considers 0 and "0" to be empty.
*
* @param mixed $data

Choose a reason for hiding this comment

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

let's keep this one

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

fabbot insists that I remove it. I reverted the changes, but it won't pass the test.

Copy link
Member

Choose a reason for hiding this comment

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

the change has not been reverted

@priyadi
Copy link
ContributorAuthor

@nicolas-grekas bump. Is there anything else I need to do before this PR can be merged?

*
* @internal
*/
class ParamFilesMerger
Copy link
Member

Choose a reason for hiding this comment

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

Instead of introducing this new internal class the code should be moved into private methods inFormUtil as the class is only used there.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

The class represents a node in the tree. It is used by itself to traverse the entire tree. The task will be very complicated without a dedicated class.

https://github.com/symfony/symfony/pull/54324/files/30c95b8c9396624a98f6e44b0f83889b77112ab7#diff-5983ae1bcb319a7efa00aa62df7a2bcfaeaabd1894959ed7994d30a79f2281deR120

Copy link
Member

Choose a reason for hiding this comment

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

I have sent a PR against your fork which inlines the methods from theParamFilesMerger class.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I have merged your PR

xabbuh reacted with thumbs up emoji
@priyadipriyadiforce-pushed thedev-fix-merge-options-form branch from4a6078e to1cf2c5fCompareMay 17, 2024 12:17
@fabpotfabpot modified the milestones:5.4,6.4Dec 14, 2024
@remyvanlerberghe
Copy link

Hi ! I noticed this PR has been open for about a year now. The bug fix you've provided here could really help us out! Would it be possible to get this moving forward again? Happy to help with anything that might be needed to get this merged

@priyadi
Copy link
ContributorAuthor

Hi ! I noticed this PR has been open for about a year now. The bug fix you've provided here could really help us out! Would it be possible to get this moving forward again? Happy to help with anything that might be needed to get this merged

I think the only thing left to do is for a maintainer to merge this PR. In the meantime, you can help by applying the fix to your project and verify if it resolves your problem.

}

return $params;
}

/**
* @param UploadedFile|array $value
Copy link
Member

Choose a reason for hiding this comment

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

this type is wrong. The value can be anything (otherwise, theis_array check on line 122 would be totally useless btw)

$this->assertArrayHasKey(0, $data);
$this->assertArrayHasKey(1, $data);

$this->assertEquals('test', $itemsForm->get('1')->get('item')->getData());
Copy link
Member

Choose a reason for hiding this comment

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

this misses assertions on$itemsForm->get('0')->get('name') and$itemsForm->get('1')->get('file')

$this->assertArrayHasKey(1, $data);

$this->assertEquals('test', $itemsForm->get('1')->get('item')->getData());
$this->assertNotNull($itemsForm->get('0')->get('file'));
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this assert the form data is not null instead of asserting that the Form instance is not null ?

Copy link
Member

Choose a reason for hiding this comment

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

btw,testMergeZeroIndexedCollection seems to have the same issue.

if (\is_array($value) && \is_array($files[$key] ?? null)) {
$params[$key] = self::mergeParamsAndFiles($value, $files[$key]);
unset($files[$key]);
$result[$key] = self::mergeAtPath($params, $files, $subPath);
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this wholemergeAtPath here which then involves reading the data at a nested path, making the whole logic more complex ?

We could be looping over all keys (which is what seemed missing before) while still merging values by passing the values at that level instead.

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

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@xabbuhxabbuhxabbuh left review comments

@ycerutoycerutoyceruto left review comments

@stofstofstof requested changes

Assignees
No one assigned
Projects
None yet
Milestone
6.4
Development

Successfully merging this pull request may close these issues.

8 participants
@priyadi@remyvanlerberghe@nicolas-grekas@stof@xabbuh@yceruto@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp