WordPress.org

Make WordPress Core

Ticket #13575: 13575.2.patch

File 13575.2.patch, 871 bytes (added by hakre, 3 years ago)

Updated patch reflecting original php.ini memory_limit value and only if memory_limit is active. Containing a filter.

  • wp-admin/includes/template.php

     
    821821        $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); 
    822822        $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); 
    823823        $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes ); 
     824 
     825        if ( function_exists( 'memory_get_usage' ) ) { 
     826                $current = ini_get( 'memory_limit' ); 
     827                ini_restore( 'memory_limit' ); 
     828                $memory_limit = ini_set( 'memory_limit',  $current ); 
     829                $m_bytes = wp_convert_hr_to_bytes( $memory_limit ); 
     830                $m_bytes = apply_filters( 'upload_size_memory_limit', $m_bytes, $bytes ); 
     831                $bytes = ( $m_bytes < 0 ) ? $bytes : min( $bytes, $m_bytes ); 
     832        } 
     833 
    824834        return $bytes; 
    825835} 
    826836