Make WordPress Core

Opened 15 months ago

Last modified 8 months ago

#55358 new defect (bug)

Passing int term term_exists parent param not respected

Reported by: spacedmonkey's profile spacedmonkey Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: good-first-bug has-patch needs-testing
Focuses: Cc:

Description

If a developer calls terms_exists, with an int as term and parent as an int, the parent value is not respected. So example this will not work.

 $term = term_exists( 123, 'category', 1);

The code will check to see if term 123 exists, but will ignore parent value. This may result in correct / unexpected results.

Attachments (2)

55358.patch (704 bytes) - added by lgadzhev 14 months ago.
Adding $parent to the query when $term is used as an int
55358.1.patch (1.0 KB) - added by lgadzhev 14 months ago.
An optimized version that avoids duplicate code

Download all attachments as: .zip

Change History (5)

#1 @lopo
14 months ago

Looks more like a problem in the docs to me than an actual bug: if you give the ID as integer you don't need to restrict by parent; if you search by string, restricting by parent can definitely be helpful.

@lgadzhev
14 months ago

Adding $parent to the query when $term is used as an int

@lgadzhev
14 months ago

An optimized version that avoids duplicate code

#2 @lgadzhev
14 months ago

  • Keywords has-patch added; needs-patch needs-unit-tests removed

Hey, I've added a patch for that. Now it is going to include $parent in the query even when $term is int

#3 @JeffPaul
8 months ago

  • Keywords needs-testing added
Note: See TracTickets for help on using tickets.