-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DomCrawler] Fix conversion to int on GetPhpFiles #24141
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
Conversation
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.
thanks, but tests are red currently :)
array_walk_recursive( | ||
$expandedValue, | ||
function (&$value, $key) { | ||
if (is_numeric($value) && in_array($key, ['size', 'error'], true)) { |
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.
is_numeric works with floats also, so better use ctype_digit here if we handle only integers, isn't it?
also, please use array(...)
instead of [...]
, or better:
('size' === $key || 'error' === $key)
10fb11c
to
7618799
Compare
7618799
to
122da5a
Compare
The PR is now updated, based on the comment above :). Thank you! |
Thank you @MaraBlaga. |
This PR was merged into the 2.7 branch. Discussion ---------- [DomCrawler] Fix conversion to int on GetPhpFiles | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | We've encountered that when using the DomCrawler with the UploadedFile, everything gets converted into strings. We've addressed the issue, and made sure that the attributes in the UploadedFile respects their type. The code below demonstrates the problem. ```<?php require 'vendor/autoload.php'; require 'app/AppKernel.php'; $crawler = new \Symfony\Component\DomCrawler\Crawler( '<form method="post"><input type="file" name="image"/></form>', 'http://www.example.com' ); $form = $crawler->filter('form')->form(); $form['image'] = new \Symfony\Component\HttpFoundation\File\UploadedFile( 'path/to/file', 'foo', 'text/plain', 100 ); $client = new \Symfony\Bundle\FrameworkBundle\Client(new AppKernel('test', true)); $crawler = $client->submit($form); var_dump($client->getRequest()->files->get('image')->getClientSize()); //returns string, not int echo 'Done.' . PHP_EOL; Commits ------- 122da5a [DomCrawler] Fix conversion to int on GetPhpFiles
We've encountered that when using the DomCrawler with the UploadedFile, everything gets converted into strings. We've addressed the issue, and made sure that the attributes in the UploadedFile respects their type.
The code below demonstrates the problem.