[wp-trac] [WordPress Trac] #24558: wp_max_upload_size does not correctly interpret post_max_size = 0
WordPress Trac
noreply at wordpress.org
Tue Jun 11 06:51:59 UTC 2013
#24558: wp_max_upload_size does not correctly interpret post_max_size = 0
--------------------------+------------------------------
Reporter: maaarghk | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 3.5
Severity: normal | Resolution:
Keywords: |
--------------------------+------------------------------
Description changed by ocean90:
Old description:
> if ini_get( 'post_max_size' ) returns 0 then there the post size is
> unlimited. WP treats this as if the max size is 0 bytes. a quick fix is
> in wp-includes/media.php : update function wp_max_upload_size() as
> follows:
>
> {
> $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize'
> ) );
> $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
> ($p_bytes == 0) ? $p_bytes = $u_bytes : $p_bytes = $p_bytes;
> $bytes = apply_filters( 'upload_size_limit', min( $u_bytes,
> $p_bytes ), $u_bytes, $p_bytes );
> return $bytes;
> }
>
> This is dirty code but does the job - I feel the proper place for the fix
> is behind the upload_size_limit filter but I don't know enough about WP
> to provide a proper patch. However, by setting post_max_size=0 and
> testing this code you should be able to reproduce the bug easily.
New description:
if ini_get( 'post_max_size' ) returns 0 then there the post size is
unlimited. WP treats this as if the max size is 0 bytes. a quick fix is in
wp-includes/media.php : update function wp_max_upload_size() as follows:
{{{
$u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize'
) );
$p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
($p_bytes == 0) ? $p_bytes = $u_bytes : $p_bytes = $p_bytes;
$bytes = apply_filters( 'upload_size_limit', min( $u_bytes,
$p_bytes ), $u_bytes, $p_bytes );
return $bytes;
}}}
This is dirty code but does the job - I feel the proper place for the fix
is behind the upload_size_limit filter but I don't know enough about WP to
provide a proper patch. However, by setting post_max_size=0 and testing
this code you should be able to reproduce the bug easily.
--
--
Ticket URL: <http://core.trac.wordpress.org/ticket/24558#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list