Opened 3 years ago
Last modified 2 years ago
#13575 new defect (bug)
wp_max_upload_size() is not taking memory limit into account
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | General | Version: | 3.0 |
| Severity: | normal | Keywords: | has-patch |
| Cc: |
Description
wp_max_upload_size() is not taking a memory limit into account while checking for the maximum upload size.
according to the official php documentation the memory limit is limiting file uploads as well (and post form operations).
post_max_size - integer
Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize. If memory limit is enabled by your configure script, memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size.
Attachments (5)
Change History (12)
- Keywords has-patch added
- Milestone changed from Unassigned to Future Release
It might be better to name the filter upload_memory_limit, so take it as suggestion only - if filtering that is even considered.
A filter is not needed here, However, the ini_get() may return incorrect information, It may have been upped already by something such as WP_MEMORY_LIMIT.
Replying to dd32:
I added a demo script which outputs the following (Fedora 13):
initial value: "128M" new value: "42M" old value: "128M" current value: "42M" original value: "128M"
So the original value should be taken into account as that's the one that comes into play at times of the upload procedure.
Updated patch reflecting original php.ini memory_limit value and only if memory_limit is active. Containing a filter.
Updated patch reflecting original php.ini memory_limit value and only if memory_limit is active. W/o a filter.
Replying to dd32:
A filter is not needed here, However, the ini_get() may return incorrect information, It may have been upped already by something such as WP_MEMORY_LIMIT.
I've uploaded some new patches that reflect both concerns, the filter and the original value. This still needs some tests (e.g. what happens if 64 MB are consumed but setting get's restored to 16 MB original value - would that do a fatal error?) but tries to address accessing the original settings value.

Related: #4240, #6735, #10495, #10830, #13418