[wp-trac] [WordPress Trac] #22061: If $this->posts is empty, don't do stuff to it

WordPress Trac noreply at wordpress.org
Sun Nov 4 03:15:39 UTC 2012


#22061: If $this->posts is empty, don't do stuff to it
----------------------------+-----------------------------
 Reporter:  wonderboymusic  |       Owner:  wonderboymusic
     Type:  defect (bug)    |      Status:  accepted
 Priority:  normal          |   Milestone:  3.5
Component:  Query           |     Version:  2.9
 Severity:  normal          |  Resolution:
 Keywords:  has-patch       |
----------------------------+-----------------------------
Changes (by wonderboymusic):

 * keywords:  has-patch reporter-feedback => has-patch
 * owner:   => wonderboymusic
 * status:  new => accepted


Comment:

 Counting an empty string equals 1 (thanks, PHP) - so I think we should
 actually expand what my previous patch had.

 Equals 1:
 {{{
 php -r "echo count('') . PHP_EOL;"
 }}}

 Because it equals 1, this would fire too:

 {{{
 if ( $this->post_count > 0 ) {
         $this->post = $this->posts[0];
 }
 }}}

 My new patch bails earlier and sets posts to empty array and post_count to
 0. Also passes all Unit Tests.

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


More information about the wp-trac mailing list