Make WordPress Core

Opened 7 years ago

Last modified 7 years ago

#39754 new defect (bug)

`_post_format_get_terms()` can overwrite names of terms in other taxonomies

Reported by: dlh's profile dlh Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch has-unit-tests
Focuses: Cc:


_post_format_get_terms() filters 'get_terms' and includes this logic:

if ( in_array( 'post_format', (array) $taxonomies ) ) {
	if ( isset( $args['fields'] ) && 'names' == $args['fields'] ) {
		foreach ( $terms as $order => $name ) {
			$terms[$order] = get_post_format_string( str_replace( 'post-format-', '', $name ) );

which affects the names of all $terms, as long as post_format was one of the queried taxonomies. Many terms are replaced with an empty string from get_post_format_string().

The attached patch includes a test to demonstrate the issue, and it would check before changing a value that the value begins with post-format- and that get_post_format_string() returns a name for the value.

Attachments (1)

39754.diff (1.5 KB) - added by dlh 7 years ago.

Download all attachments as: .zip

Change History (2)

7 years ago

#1 @dlh
7 years ago

  • Keywords has-patch has-unit-tests added
Note: See TracTickets for help on using tickets.