Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ function size_format( $bytes, $decimals = 0 ) {
_x( 'B', 'unit symbol' ) => 1,
);

$bytes = (int) $bytes;
if ( 0 === $bytes ) {
/* translators: Unit symbol for byte. */
return number_format_i18n( 0, $decimals ) . ' ' . _x( 'B', 'unit symbol' );
Expand Down
3 changes: 3 additions & 0 deletions tests/phpunit/tests/functions/sizeFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function data_size_format() {
array( -1, 0, false ),
// Bytes.
array( 0, 0, '0 B' ),
array( '0', 0, '0 B' ),
array( '0.0', 0, '0 B' ),
array( 0.0e3, 0, '0 B' ),
array( 1, 0, '1 B' ),
array( 1023, 0, '1,023 B' ),
// Kilobytes.
Expand Down
Loading