[wp-trac] [WordPress Trac] #20633: wp-includes/comment.php:738 - Undefined property: WP_Query::$comments

WordPress Trac noreply at wordpress.org
Tue Mar 12 17:24:30 UTC 2013


#20633: wp-includes/comment.php:738 - Undefined property: WP_Query::$comments
------------------------------+------------------------------
 Reporter:  markjaquith       |       Owner:
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Warnings/Notices  |     Version:  3.3.2
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |
------------------------------+------------------------------

Comment (by kitchin):

 The patch is not correct. It does this:

 {{{
 - if ( !$comments || !is_array($comments) )
 + if ( ( !$comments || !is_array($comments) ) && !empty(
 $wp_query->comments ) )
     $comments = $wp_query->comments;
   if ( empty($comments) )
     return 0;
 }}}

 The patch defeats the is_array() check. For example, $comments=true,
 $wp_query->comments=null will not return 0.

 Suggest:
 {{{
 - if ( !$comments || !is_array($comments) )
 + if ( empty($comments) || !is_array($comments) ) {
 +   if (empty( $wp_query->comments ) )
 +     return 0;
     $comments = $wp_query->comments;
 + }
 - if ( empty($comments) )
 -    return 0;
 }}}

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


More information about the wp-trac mailing list