mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Avoid an undefined offset notice in wp_convert_bytes_to_hr(). props soulseekah. fixes #23626.
git-svn-id: http://core.svn.wordpress.org/trunk@23502 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b6e33d56f9
commit
0cff4a5ea9
@ -3377,9 +3377,18 @@ function gd_edit_image_support($mime_type) {
|
|||||||
*/
|
*/
|
||||||
function wp_convert_bytes_to_hr( $bytes ) {
|
function wp_convert_bytes_to_hr( $bytes ) {
|
||||||
_deprecated_function( __FUNCTION__, '3.6', 'size_format()' );
|
_deprecated_function( __FUNCTION__, '3.6', 'size_format()' );
|
||||||
|
|
||||||
$units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
|
$units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
|
||||||
$log = log( $bytes, 1024 );
|
$log = log( $bytes, 1024 );
|
||||||
$power = (int) $log;
|
$power = (int) $log;
|
||||||
|
|
||||||
|
if ( array_key_exists( $power, $units ) ) {
|
||||||
$size = pow( 1024, $log - $power );
|
$size = pow( 1024, $log - $power );
|
||||||
return $size . $units[$power];
|
$unit = $units[ $power ];
|
||||||
|
} else {
|
||||||
|
$size = $bytes;
|
||||||
|
$unit = $units[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $size . $unit;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user