Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#29192 closed defect (bug) (duplicate)

Twenty Fourteen: Featured_Content::hide_featured_term() triggers notice when using get_terms()

Reported by: dnaber-de's profile dnaber-de Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9.1
Component: Bundled Theme Keywords:
Focuses: Cc:

Description

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;
} );

Attachments (1)

29192.diff (1.3 KB) - added by dnaber-de 10 years ago.

Download all attachments as: .zip

Change History (4)

@dnaber-de
10 years ago

#1 @dnaber-de
10 years ago

  • Keywords has-patch needs-unit-tests added

#2 @dnaber-de
10 years ago

Obviously a duplicate of #28072

Last edited 10 years ago by SergeyBiryukov (previous) (diff)

#3 @ocean90
10 years ago

  • Keywords has-patch needs-unit-tests removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Summary changed from Twentyfourteen: Featured_Content::hide_featured_term() triggers notice when using get_terms() to Twenty Fourteen: Featured_Content::hide_featured_term() triggers notice when using get_terms()

Duplicate of #28072.

Note: See TracTickets for help on using tickets.