[wp-trac] [WordPress Trac] #14184: empty() and "0" in class-http.php

WordPress Trac wp-trac at lists.automattic.com
Sun Jul 4 15:16:50 UTC 2010


#14184: empty() and "0" in class-http.php
--------------------------+-------------------------------------------------
 Reporter:  mailnew2ster  |       Owner:                         
     Type:  defect (bug)  |      Status:  new                    
 Priority:  normal        |   Milestone:  Awaiting Review        
Component:  HTTP          |     Version:                         
 Severity:  normal        |    Keywords:  has-patch needs-testing
--------------------------+-------------------------------------------------

Comment(by jacobsantos):

 Replying to [comment:2 mailnew2ster]:
 > Most of them are. empty() is used, for example, to check whether the
 response is empty, which "0" is not, etc.

 I disagree, in many of the cases the empty() check is needed, because we
 aren't just comparing against strings and others because it won't matter.
 Line 447 is the only one I can see so far looking through half the ticket
 where changing it fixes a behavior problem. The reason are either checking
 for values that are empty other than "", or are strings in situations
 where the other empty values won't be an issue.

 > As of $length = hexdec( $match[1] );, empty() used there to check for
 "0", but it does not return true for, eg., "00", thus it's better to use
 hexdec first, and then check the integer for 0.

 During my research all of the examples and live tests had '0' as the last
 number. If you are seeing '00', then yes, I think for optimization, it
 should be corrected. Take for example if '00' is encountered, nothing
 adverse is going to happen. The length check is going to return 0, so
 nothing is going to be appended to the body and it will end the loop. I
 believe more servers are going to be sending a '0' for the ending chunk
 than '00'.

 Correct me if I'm wrong.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14184#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list