WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#16951 closed defect (bug) (fixed)

register_taxonomy_for_object_type() sets duplicate values

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

Description

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 3 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 scribu3 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 3 years ago by scribu (previous) (diff)

comment:2 kevinB3 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?

comment:3 scribu3 years ago

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

Makes sense. Patch is dead simple.

comment:4 dd323 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.