Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#32590 closed defect (bug) (fixed)

Malformed `object_types` when using `register_taxonomy_for_object_type()` on taxonomy that doesn't already have object types

Reported by: boonebgorges's profile boonebgorges Owned by: boonebgorges's profile boonebgorges
Milestone: 4.3 Priority: low
Severity: normal Version:
Component: Taxonomy Keywords:
Focuses: Cc:


If you register a taxonomy with an empty $object_type, eg

register_taxonomy( 'foo', '' );

and later on decide to register the taxonomy with a post type:

register_taxonomy_for_object_type( 'foo', 'post' );

the 'object_types' property of the taxonomy object will be an array of the form:


This can cause various sorts of weirdness. The issue I ran into is that the 'update_count_callback' fallback ends up being _update_generic_term_count() instead of the correct _update_post_term_count(), because of the array_filter() check here:

Change History (1)

#1 @boonebgorges
9 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 32709:

Filter out empty object_types in register_taxonomy_for_object_type().

This prevents weird edge bugs when registering an existing taxonomy with an
object type when the taxonomy was previously associated with no object types.

Fixes #32590.

Note: See TracTickets for help on using tickets.