[wp-trac] [WordPress Trac] #16717: Wrong error handling in query.php::get_posts()

WordPress Trac wp-trac at lists.automattic.com
Tue Mar 1 14:31:00 UTC 2011


#16717: Wrong error handling in query.php::get_posts()
--------------------------+-----------------------------
 Reporter:  fabifott      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  3.1
 Severity:  minor         |   Keywords:
--------------------------+-----------------------------
 The bug seems to be in a back compat block, so not very important:
 In lines 2187 and 2199 get_term_by() is called. In following line it is
 just checked if it returns are logical true value.:
 {{{
 $the_cat = get_term_by( $cat_query['field'], $cat_query['terms'][0],
 'category' );
 if ( $the_cat ) {
         $this->set( 'cat', $the_cat->term_id );
         $this->set( 'category_name', $the_cat->slug );
 }
 }}}

 But get_term_by calls get_term(), and this function can return WP_Error.
 As a result, the error is not handled properly. This caused several
 warnings in Debug Mode, since the WP_Error object is treated as a Category
 object. The bug is actually in get_term_by() since it returns false in
 error case by definition.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16717>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list