[wp-trac] [WordPress Trac] #12212: post__in can't manage empty array properly

WordPress Trac wp-trac at lists.automattic.com
Fri Feb 12 11:08:41 UTC 2010


#12212: post__in can't manage empty array properly
--------------------------+-------------------------------------------------
 Reporter:  lifeless85    |       Owner:  ryan          
     Type:  defect (bug)  |      Status:  new           
 Priority:  high          |   Milestone:  Future Release
Component:  Query         |     Version:  2.9.1         
 Severity:  major         |    Keywords:  post__in      
--------------------------+-------------------------------------------------

Comment(by lifeless85):

 i think a good soludion should be changing
 {{{
 elseif ( $q['post__in'] ) {
         $post__in = implode(',', array_map( 'absint', $q['post__in'] ));
         $where .= " AND {$wpdb->posts}.ID IN ($post__in)";
 }
 }}}
 to
 {{{
 elseif ( $q['post__in'] ) {
         if ( empty( array_map( 'absint', $q['post__in'] ))){
                 $where .= " AND {$wpdb->posts}.ID = NULL
         }
         else {
                 $post__in = implode(',', array_map( 'absint',
 $q['post__in'] ));
                 $where .= " AND {$wpdb->posts}.ID IN ($post__in)";
         }
 }
 }}}

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


More information about the wp-trac mailing list