http://www.sfu.ca/~jdbates/tmp/drupal/200910300/patch
My upload_max_filesize php.ini directive is set to "0" (zero), so there is no PHP per file upload maximum file size, I can upload files of any size, so long as the total request doesn't exceed the post_max_size php.ini directive
However, I can't set a Drupal "default maximum file size per upload"
When I enter any value into this field on the "file uploads" configuration page, and submit, Drupal displays an error, "Your PHP settings limit the maximum file size per upload to 0 bytes."
To reproduce, set php.ini directives post_max_size to e.g. "8M" and upload_max_filesize to "0"
Enter any value into the "default maximum file site per upload" field on the "file uploads" configuration page, and submit
This patch fixes this by correctly interpreting an upload_max_filesize value of "0" as unlimited
With this patch applied, I can successfully set a Drupal "default maximum file size per upload", provided it's less than the post_max_size
- if I try entering a value which exceeds the post_max_size, Drupal correctly displays an error, e.g. "Your PHP settings limit the maximum file size per upload to 8 MB."
Comment | File | Size | Author |
---|---|---|---|
#11 | 619434-11.patch | 758 bytes | thedavidmeister |
#8 | 619434-8.patch | 892 bytes | jablko |
#5 | 619434b.patch | 1.07 KB | jim0203 |
#1 | 619434.patch | 784 bytes | jim0203 |
Comments
Comment #1
jim0203 CreditAttribution: jim0203 commentedAttaching the patch to the issue so the bot reviews it and I can use dreditor with it :-).
Comment #2
jim0203 CreditAttribution: jim0203 commentedRecreated the bug as per instructions on my clean D7 install. The patch fixes the bug and the code is clean. Set to RTBC.
Comment #3
webchickThis makes sense. I'm trying to figure out how we could test this, though. Is it possible for a test to set post_max_size and upload_max_filesize to ridiculously small numbers and then attempt to upload one of the files from the SimpleTest files directory?
Comment #4
webchickTo answer my own question, it looks like the answer is no:
In both instances of phpinfo(), I get the same result.
However, let's comment this a bit better so it explains the interaction between upload_max_filesize and post_max_size. There's useful information in this issue that's not grokkable from the source code. Also, make sure that all comments end in a period, for consistency.
Comment #5
jim0203 CreditAttribution: jim0203 commentedThanks, webchick. Have added comments; new patch attached.
Comment #6
jim0203 CreditAttribution: jim0203 commentedChanging status.
Comment #7
MichaelCole CreditAttribution: MichaelCole commented#5: 619434b.patch queued for re-testing.
Comment #8
jablko CreditAttribution: jablko commentedI reproduced today with D7 from CVS
I set php.ini directives post_max_size to e.g. "8M" and upload_max_filesize to "0"
The "file uploads" page has moved since I reported this issue - now I go to "structure" in the dashboard, "content types", and click "edit" next to "article"
Click "manage fields" and click "edit" next to the "image" field
Currently under "maximum upload size" I see, "If left empty the file sizes will be limited only by PHP's maximum post and file upload sizes (current limit 0 bytes)."
This patch fixes current limit, so I see e.g. "current limit 8 MB"
Currently I can save any value in the "maximum upload size", including values greater than the "current limit", or the string "banana" - will report as a new issue
Comment #9
ngstigator CreditAttribution: ngstigator commentedReproduced on clean D7 install. Applied patch and works as advertised.
I've noticed that the field does not validate values that exceed "post_max_size" nor strings like "banana" (thx webchick). Searching issue queue for this.
UPDATE: separate issue created for this #870576: Insufficient validation of the max upload file size field
Comment #10
webchickNice work on the comments, thanks! Also great work cleaning up the legibility of that code.
Committed to HEAD. :) Welcome to the core team, jablko and chris_five! :D
Looks like this applies with an offset to 6.x too. If we could get a quick test on that, go ahead and bump back to RTBC.
Comment #11
thedavidmeister CreditAttribution: thedavidmeister commentedrerolled for d6.