[wp-trac] [WordPress Trac] #29192: Twentyfourteen: Featured_Content::hide_featured_term() triggers notice when using get_terms()

WordPress Trac noreply at wordpress.org
Tue Aug 12 11:16:47 UTC 2014


#29192: Twentyfourteen: Featured_Content::hide_featured_term() triggers notice when
using get_terms()
---------------------------+-----------------------------
 Reporter:  dnaber-de      |      Owner:
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Bundled Theme  |    Version:  3.9.1
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 `Featured_Content::hide_featured_term()`, which is a callback on the
 filter `get_terms` assumes that the first parameter is always an array of
 `stdClass` objects.

 `get_terms()` provides the possibility to fetch only term IDs and so the
 filter pass an array as numeric values to the callback, which then causes
 the following error:


 {{{
 Notice: Trying to get property of non-object in /var/www/wp-
 content/themes/twentyfourteen/inc/featured-content.php on line 334
 }}}


 In fact, every possible value of the `fields` parameter besides `all` and
 `count` triggers this error.

 The Following Plugin reproduces the Error, if at least one term of
 `post_tag` taxonomy exists:


 {{{
 <?php
 /**
  * Plugin Name: Test
  */
 add_filter( 'the_content', function( $content ) {

         $terms = get_terms(
                 'post_tag',
                 array(
                         'hide_empty' => FALSE,
                         'fields'     => 'ids'
                 )
         );

         return $content;
 } );
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29192>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list