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

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@MaraBlaga
Copy link
Contributor

@MaraBlagaMaraBlaga commentedSep 8, 2017
edited
Loading

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets
LicenseMIT
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.

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 intecho 'Done.' . PHP_EOL;

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.

thanks, but tests are red currently :)

array_walk_recursive(
$expandedValue,
function (&$value,$key) {
if (is_numeric($value) &&in_array($key, ['size','error'],true)) {
Copy link
Member

@nicolas-grekasnicolas-grekasSep 9, 2017
edited
Loading

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 usearray(...) instead of[...], or better:
('size' === $key || 'error' === $key)

@MaraBlagaMaraBlagaforce-pushed theConvert-to-int-on-GetPhpFiles branch 3 times, most recently from10fb11c to7618799CompareSeptember 11, 2017 13:53
@MaraBlagaMaraBlagaforce-pushed theConvert-to-int-on-GetPhpFiles branch from7618799 to122da5aCompareSeptember 11, 2017 14:11
@MaraBlaga
Copy link
ContributorAuthor

The PR is now updated, based on the comment above :). Thank you!

@fabpot
Copy link
Member

Thank you@MaraBlaga.

@fabpotfabpot merged commit122da5a intosymfony:2.7Sep 11, 2017
fabpot added a commit that referenced this pull requestSep 11, 2017
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.```<?phprequire '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 intecho 'Done.' . PHP_EOL;Commits-------122da5a [DomCrawler] Fix conversion to int on GetPhpFiles
@fabpotfabpot mentioned this pull requestSep 11, 2017
This was referencedOct 5, 2017
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

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

5 participants

@MaraBlaga@fabpot@nicolas-grekas@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp