WordPress.org

Make WordPress Core

Ticket #17725: 17725.2.diff

File 17725.2.diff, 1.1 KB (added by hakre, 7 years ago)

Additional patch related to #14889

  • wp-admin/includes/template.php

     
    779779}
    780780
    781781/**
    782  * {@internal Missing Short Description}}
     782 * Convert a human readable (hr) memory setting value as in
     783 * php.ini into the number of bytes (Shorthand Notation).
    783784 *
    784785 * @since 2.3.0
    785786 *
    786  * @param unknown_type $size
    787  * @return unknown
     787 * @param string $size memory setting value
     788 * @return float bytes
    788789 */
    789790function wp_convert_hr_to_bytes( $size ) {
    790         $size = strtolower($size);
    791         $bytes = (int) $size;
    792         if ( strpos($size, 'k') !== false )
    793                 $bytes = intval($size) * 1024;
    794         elseif ( strpos($size, 'm') !== false )
    795                 $bytes = intval($size) * 1024 * 1024;
    796         elseif ( strpos($size, 'g') !== false )
    797                 $bytes = intval($size) * 1024 * 1024 * 1024;
    798         return $bytes;
     791        $bytes = (float) $size;
     792        $last = strtolower( substr( $size, -1 ) );
     793        $pos = strpos( ' kmg', $last , 1);
     794        if ( $pos ) $bytes *= pow( 1024, $pos);
     795        return round( $bytes );
    799796}
    800797
    801798/**