Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#16951 closed defect (bug) (fixed)

register_taxonomy_for_object_type() sets duplicate values

Reported by: kevinb's profile kevinB Owned by: scribu's profile scribu
Milestone: 3.2 Priority: normal
Severity: minor Version: 3.1
Component: Taxonomy Keywords: has-patch commit
Focuses: Cc:


If register_taxonomy_for_object_type() is called for an object type which is already present in the taxonomy's object_type array, a duplicate value is added to the array.

This is a common occurrence with user-modifiable taxonomy/type definition in plugins such as GD Custom Posts and Taxonomies, when:

  • register_taxonomy() is called with object_type argument, based on a taxonomy configuration.
  • register_taxonomy_for_object_type() is subsequently called, based on a post type configuration.

Attachments (1)

reg_tx_for_otype-no_dupes.patch (459 bytes) - added by kevinB 13 years ago.

Download all attachments as: .zip

Change History (5)

#1 @scribu
13 years ago

  • Owner set to scribu
  • Severity changed from normal to minor
  • Status changed from new to reviewing

Do duplicates there actually have any adverse effects?

Last edited 13 years ago by scribu (previous) (diff)

#2 @kevinB
13 years ago

It can cause redundant processing or duplicate/erroneous UI generation in taxonomy-related plugins.

You're right to flag it as minor, but it's also a minor fix. My thinking is if $tx->object_type is supported API, are duplicate object_type values ever appropriate and if not, why leave validation to the client?

#3 @scribu
13 years ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 3.2

Makes sense. Patch is dead simple.

#4 @dd32
13 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

(In [17688]) Prevent $taxonony->object_type containing duplicate values. Initial patch props kevinB. Fixes #16951

Note: See TracTickets for help on using tickets.