[wp-trac] [WordPress Trac] #61930: size_format(): Inconsistent behaviour when zero bytes are passed

WordPress Trac noreply at wordpress.org
Mon Sep 2 13:05:56 UTC 2024


#61930: size_format(): Inconsistent behaviour when zero bytes are passed
--------------------------+------------------------------
 Reporter:  marian1       |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  6.6.1
 Severity:  trivial       |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by devmooz):

 To handle both cases (integer 0 and string '0'), the proposed fix checks
 for both explicitly:

 {{{
 if ( 0 === $bytes || '0' === $bytes ) {
 }}}
 {{{#!php
 <?php
 if ( 0 === $bytes || '0' === $bytes ) {

 }}}
 Impact:
 With the Fix: Both 0 (integer) and '0' (string) will result in the
 function returning false, restoring the behavior before WP 4.6.0.

 Without the Fix: The function behaves inconsistently, depending on whether
 0 is passed as an integer or a string.

 This fix aligns with the intended behavior of the function, ensuring that
 both 0 and '0' are treated equivalently.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61930#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list