Opened 4 months ago
Last modified 2 months ago
#61930 new defect (bug)
size_format(): Inconsistent behaviour when zero bytes are passed
Reported by: | marian1 | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | trivial | Version: | 4.6 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
The size_format()
function returns false
if zero is passed as a string and returns '0 B'
if zero is passed as an integer.
The root cause is a strict comparison when checking against zero (if ( 0 === $bytes ) {
). If the $bytes
parameter is passed as a string ('0'
), the condition fails.
Proposed Fix: if ( 0 === $bytes || '0' === $bytes ) {
This behaviour was introduced in WP 4.6.0. Before v4.6.0, both 0
and '0'
resulted in size_format()
returning false
.
Change History (3)
This ticket was mentioned in PR #7248 on WordPress/wordpress-develop by @narenin.
3 months ago
#1
- Keywords has-patch added
#2
@
3 months ago
- Keywords has-patch removed
Hi @marian1
Welcome to the Core Trac!
Thanks for the detailed information.
I have added the patch for the same.
#5
@
3 months ago
- Version changed from 6.6.1 to 4.6
Note: See
TracTickets for help on using
tickets.
Trac ticket: https://core.trac.wordpress.org/ticket/61930