From 0cff4a5ea9bb17ed1db7b7d918aa6f4a6306759a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 28 Feb 2013 05:25:15 +0000 Subject: [PATCH] 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 --- wp-includes/deprecated.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index bde4ea8c7b..f1e8e642e3 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -3377,9 +3377,18 @@ function gd_edit_image_support($mime_type) { */ function wp_convert_bytes_to_hr( $bytes ) { _deprecated_function( __FUNCTION__, '3.6', 'size_format()' ); + $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' ); $log = log( $bytes, 1024 ); $power = (int) $log; - $size = pow( 1024, $log - $power ); - return $size . $units[$power]; + + if ( array_key_exists( $power, $units ) ) { + $size = pow( 1024, $log - $power ); + $unit = $units[ $power ]; + } else { + $size = $bytes; + $unit = $units[0]; + } + + return $size . $unit; }