WordPress.org

Make WordPress Core

#45698 closed defect (bug) (fixed)

`get_{$taxonomy}` filter misfires when `$taxonomy` parameter is omitted

Reported by: dlh Owned by: boonebgorges
Milestone: 5.1 Priority: normal
Severity: normal Version: 4.4
Component: Taxonomy Keywords: has-patch
Focuses: Cc:
PR Number:

Description (last modified by dlh)

[34997] made the $taxonomy parameter to get_term() optional. However, when no $taxonomy is passed, no $taxonomy is available for the dynamic get_{$taxonomy} filter, so the less-exciting get_ filter is applied instead. Additionally, no $taxonomy is passed to the get_term filter.

The attached patch would set $taxonomy to that of the retrieved term before the get_term and get_{$taxonomy} filters are applied.

14162.3.patch:ticket:14162 on the original ticket includes the same adjustment, but it seems to have been missed, or I am missing something.

Attachments (1)

45698.diff (431 bytes) - added by dlh 10 months ago.

Download all attachments as: .zip

Change History (4)

@dlh
10 months ago

#1 @dlh
10 months ago

  • Description modified (diff)

#2 @boonebgorges
10 months ago

  • Milestone changed from Awaiting Review to 5.1

Thanks, @dlh. This was almost certainly an oversight when introducing WP_Term.

#3 @boonebgorges
10 months ago

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

In 44325:

Ensure that taxonomy name passed to get_term() filters is non-empty.

Since [34997], the $taxonomy parameter of get_term() has been
optional. This created cases where the $taxonomy parameter, used
to concatenate names for some filters and passed as a parameter to
others, would be empty. This changeset ensures that it's never
empty by falling back on the taxonomy of the located term.

Props dlh.
Fixes #45698.

Note: See TracTickets for help on using tickets.