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

[HttpFoundation] FixgetMaxFilesize#32790

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
nicolas-grekas merged 1 commit intosymfony:3.4frombennyborn:fix_maxfilesize
Jul 30, 2019
Merged

[HttpFoundation] FixgetMaxFilesize#32790

nicolas-grekas merged 1 commit intosymfony:3.4frombennyborn:fix_maxfilesize
Jul 30, 2019

Conversation

@bennyborn
Copy link
Contributor

When checking for the maximum size of an uploaded file you can't just rely onupload_max_filesize since the request might also exceedpost_max_size. Also discussed incontao/contao#498

QA
Branch?3.4
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets-
LicenseMIT
Doc PR-

fritzmg reacted with thumbs up emoji
publicstaticfunctiongetMaxFilesize()
{
$iniMax =strtolower(ini_get('upload_max_filesize'));
$iniMax =min([ini_get('upload_max_filesize'),ini_get('post_max_size')]);

Choose a reason for hiding this comment

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

min() cannot work here, we should parse post_max_size before calling it, as it can be a string with units (e.g. 8M)
please also add test cases

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Your're right. Would it be okay to add anparseFilesize to the class? Also since there seems to be no test forgetMaxFilesize till now I'm not entirely sure how to create one since it depends on the ini settings.

Choose a reason for hiding this comment

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

Would it be okay to add an parseFilesize to the class

a private one yes,

not entirely sure how to create one since it depends on the ini settings

dunno if it's possible to use ini_set here... if not, I don't know either :)

bennyborn reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Well, I've implemented the proper conversion and check on the two values but regarding the tests it seems we're out of luck. We can't set e.g.upload_max_filesize usingini_set() becauseupload_max_filesize is aPHP_INI_PERDIR type which means it's only changeable via php.ini, .htaccess or httpd.conf ( seephp.net/manual/en/configuration.changes.modes.php)

That also explains why there was no test on this method to begin with.

@xabbuh
Copy link
Member

Can we add a test case for this?

@nicolas-grekas
Copy link
Member

Not sure, see#32790 (comment)

xabbuh reacted with thumbs up emoji

@nicolas-grekas
Copy link
Member

Thank you@bennyborn.

@nicolas-grekasnicolas-grekas merged commit54107ba intosymfony:3.4Jul 30, 2019
nicolas-grekas added a commit that referenced this pull requestJul 30, 2019
This PR was squashed before being merged into the 3.4 branch (closes#32790).Discussion----------[HttpFoundation] Fix `getMaxFilesize`When checking for the maximum size of an uploaded file you can't just rely on `upload_max_filesize` since the request might also exceed `post_max_size`. Also discussed incontao/contao#498| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -Commits-------54107ba [HttpFoundation] Fix `getMaxFilesize`
@bennyborn
Copy link
ContributorAuthor

Thank you@bennyborn.

No worries, glad I could help!

fabpot added a commit that referenced this pull requestAug 14, 2019
This PR was merged into the 3.4 branch.Discussion----------Fix getMaxFilesize() returning zero| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#32790| License       | MITWith#32790 a BC break got introduced. Previously an empty `upload_max_filesize` returned `PHP_INT_MAX` but after the changes from#32790 it returns `0`.Setting `upload_max_filesize` or `post_max_size` to `0` or `''` disables the limit so for both cases `PHP_INT_MAX` should be returned.Commits-------f4c2ea5 Fix getMaxFilesize() returning zero
This was referencedAug 26, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@xabbuhxabbuhxabbuh approved these changes

@ycerutoycerutoyceruto approved these changes

+1 more reviewer

@ToflarToflarToflar approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

7 participants

@bennyborn@xabbuh@nicolas-grekas@ausi@Toflar@yceruto@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp