WordPress.org

Make WordPress Core

Ticket #17725: 17725.diff

File 17725.diff, 1.2 KB (added by hakre, 7 years ago)

Use float instad of int.

  • 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        if ( 'k' === $last )
     794                $bytes *= 1024;
     795        elseif ( 'm' === $last )
     796                $bytes *= 1024 * 1024;
     797        elseif ( 'g' === $last )
     798                $bytes *= 1024 * 1024 * 1024;
     799        return round( $bytes );
    799800}
    800801
    801802/**