From aea4c0d86a4787c336d061b2457ba74e24c80140 Mon Sep 17 00:00:00 2001 From: SergeyBiryukov Date: Tue, 14 Jun 2016 21:40:02 +0000 Subject: [PATCH] In `size_format()` and `wp_convert_bytes_to_hr()`, replace `kB` with `KB` for consistency with other units. Props Presskopp, dashaluna. Fixes #37037. git-svn-id: https://develop.svn.wordpress.org/trunk@37702 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/deprecated.php | 2 +- src/wp-includes/functions.php | 4 ++-- tests/phpunit/tests/media.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/deprecated.php b/src/wp-includes/deprecated.php index f3a95c521b..ae1dce5e1e 100644 --- a/src/wp-includes/deprecated.php +++ b/src/wp-includes/deprecated.php @@ -3329,7 +3329,7 @@ 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', 4 => 'TB' ); + $units = array( 0 => 'B', 1 => 'KB', 2 => 'MB', 3 => 'GB', 4 => 'TB' ); $log = log( $bytes, KB_IN_BYTES ); $power = (int) $log; $size = pow( KB_IN_BYTES, $log - $power ); diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index a39e7034cb..497d264a89 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -237,7 +237,7 @@ function number_format_i18n( $number, $decimals = 0 ) { /** * Convert number of bytes largest unit bytes will fit into. * - * It is easier to read 1 kB than 1024 bytes and 1 MB than 1048576 bytes. Converts + * It is easier to read 1 KB than 1024 bytes and 1 MB than 1048576 bytes. Converts * number of bytes to human readable number by taking the number of that unit * that the bytes will go into it. Supports TB value. * @@ -259,7 +259,7 @@ function size_format( $bytes, $decimals = 0 ) { 'TB' => TB_IN_BYTES, 'GB' => GB_IN_BYTES, 'MB' => MB_IN_BYTES, - 'kB' => KB_IN_BYTES, + 'KB' => KB_IN_BYTES, 'B' => 1, ); diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index 5faa0cfae7..55311a5766 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -273,12 +273,12 @@ https://w.org' $this->assertEquals( '1TB', wp_convert_bytes_to_hr( $tb ) ); $this->assertEquals( '1GB', wp_convert_bytes_to_hr( $gb ) ); $this->assertEquals( '1MB', wp_convert_bytes_to_hr( $mb ) ); - $this->assertEquals( '1kB', wp_convert_bytes_to_hr( $kb ) ); + $this->assertEquals( '1KB', wp_convert_bytes_to_hr( $kb ) ); $this->assertEquals( '1 TB', size_format( $tb ) ); $this->assertEquals( '1 GB', size_format( $gb ) ); $this->assertEquals( '1 MB', size_format( $mb ) ); - $this->assertEquals( '1 kB', size_format( $kb ) ); + $this->assertEquals( '1 KB', size_format( $kb ) ); // now some values around $hr = wp_convert_bytes_to_hr( $tb + $tb / 2 + $mb );