Bootstrap: Clean up `wp_convert_hr_to_bytes()`.
* Don't return a value higher than `PHP_INT_MAX`. * Add unit tests. Props jrf. See #32075. Built from https://develop.svn.wordpress.org/trunk@38013 git-svn-id: http://core.svn.wordpress.org/trunk@37954 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5eae48b414
commit
682e028a5a
|
@ -956,7 +956,7 @@ function wp_installing( $is_installing = null ) {
|
|||
* Determines if SSL is used.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @since 4.6.0 Moved from functions.php to load.php
|
||||
* @since 4.6.0 Moved from functions.php to load.php.
|
||||
*
|
||||
* @return bool True if SSL, otherwise false.
|
||||
*/
|
||||
|
@ -979,19 +979,26 @@ function is_ssl() {
|
|||
* Converts a shorthand byte value to an integer byte value.
|
||||
*
|
||||
* @since 2.3.0
|
||||
* @since 4.6.0 Moved from media.php to load.php
|
||||
* @since 4.6.0 Moved from media.php to load.php.
|
||||
*
|
||||
* @param string $size A shorthand byte value.
|
||||
* @link http://php.net/manual/en/function.ini-get.php
|
||||
* @link http://php.net/manual/en/faq.using.php#faq.using.shorthandbytes
|
||||
*
|
||||
* @param string $value A (PHP ini) byte value, either shorthand or ordinary.
|
||||
* @return int An integer byte value.
|
||||
*/
|
||||
function wp_convert_hr_to_bytes( $size ) {
|
||||
$size = strtolower( $size );
|
||||
$bytes = (int) $size;
|
||||
if ( strpos( $size, 'k' ) !== false )
|
||||
$bytes = intval( $size ) * KB_IN_BYTES;
|
||||
elseif ( strpos( $size, 'm' ) !== false )
|
||||
$bytes = intval($size) * MB_IN_BYTES;
|
||||
elseif ( strpos( $size, 'g' ) !== false )
|
||||
$bytes = intval( $size ) * GB_IN_BYTES;
|
||||
return $bytes;
|
||||
function wp_convert_hr_to_bytes( $value ) {
|
||||
$value = strtolower( trim( $value ) );
|
||||
$bytes = (int) $value;
|
||||
|
||||
if ( false !== strpos( $value, 'g' ) ) {
|
||||
$bytes *= GB_IN_BYTES;
|
||||
} elseif ( false !== strpos( $value, 'm' ) ) {
|
||||
$bytes *= MB_IN_BYTES;
|
||||
} elseif ( false !== strpos( $value, 'k' ) ) {
|
||||
$bytes *= KB_IN_BYTES;
|
||||
}
|
||||
|
||||
// Deal with large (float) values which run into the maximum integer size.
|
||||
return min( $bytes, PHP_INT_MAX );
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.6-beta2-38012';
|
||||
$wp_version = '4.6-beta2-38013';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue