-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DomCrawler] phpFiles array is generated wrongly for fields with more than one level #14021
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
Comments
Hi @albe, I'm not sure if I understand your issue. Can you please provide an example HTML snippet and how you used the DomCrawler component? |
Sorry for the short description. I'm using it in TYPO3 Flow currently for writing (functional) tests. There DomCrawler is used to simulate a browser to send a request from given HTML forms. So here is an example to show the behaviour: $html = <<<'HTML'
<!DOCTYPE html>
<html>
<body>
<form method="post">
<input type="file" name="post[upload]" />
</form>
</body>
</html>
HTML;
$crawler = new \Symfony\Component\DomCrawler\Crawler($html, 'http://localhost');
$form = $crawler->filterXPath('//form')->form();
var_dump($form->getPhpFiles()); The output is as given above, while submitting this form in a browser and handling it with PHP var_dump'ing $_FILES, it gives the expected output. Just let me know if you need any further information on this issue. |
Correct. I think this is a bug, as here's what we promise in
like PHP does part is currently a lie. Looks like it never worked properly. There's even a test verifying invalid behaviour. Changing it at this point might be problematic due to BC promise :( |
Yeah ok, I understand that :) But really should be adressed in the next major update that is breaking BC |
I created a pull request with a possible solution that I use locally for the time being. That solution is not complete though, since getPhpValues (and maybe other places I don't know of) might need change too. Still in any case you consider fixing this, you can use that as base freely to your liking. |
This can be closed? |
@dosten it hasn't been resolved in any way yet. |
… (jakzal) This PR was merged into the 2.3 branch. Discussion ---------- [DomCrawler] Clarify the value returned by getPhpFiles() | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14021 | License | MIT | Doc PR | - The comment was previously suggesting the returned value is similar to the one stored in $_FILES, while it is more similar to the way PHP stores submitted form values. It is actually more convenient to have it this way, so rather then changing the returned value (which would break BC), it is better to clarify the comment. Commits ------- a694401 [DomCrawler] Clarify the value returned by getPhpFiles()
Symfony DomCrawler is broken for file uploads. It creates a wrongly formatted phpFiles array, when the submit field has more than one level, e.g. "post[upload]" will create
instead of the expected that PHP creates
The text was updated successfully, but these errors were encountered: