Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#14590 closed defect (bug) (fixed)

get_queried_object_id does not return an int for taxonomy terms

Reported by: GamajoTech Owned by:
Milestone: 3.1 Priority: normal
Severity: minor Version: 3.0.1
Component: Taxonomy Keywords: has-patch needs-testing gsoc
Focuses: Cc:


The docblock for get_queried_object_id() claims it returns as an integer. However, when the queried object is such that is_tax() as true, it's returned as a string.

The following line (currently line 2739 of wp-includes/query.php in WP 3.0.1) needs changing within get_queried_object() from:

$this->queried_object_id = $term->term_id;


$this->queried_object_id = (int) $term->term_id;

Attachments (1)

14590.diff (541 bytes) - added by wojtek.szkutnik 5 years ago.

Download all attachments as: .zip

Change History (8)

#1 @wojtek.szkutnik
5 years ago

  • Cc wojtek.szkutnik@… added
  • Keywords has-patch needs-testing gsoc added; taxonomy get_queried_object removed

Clearly someone must have forgotten the (int) part. I double checked the rest of the code, it seems it's the only place where the problem appears.

#2 @scribu
5 years ago

  • Severity changed from normal to minor

#3 @GamajoTech
5 years ago

  • Cc gary@… added

Thanks for taking a look and attaching a patch (I really should learn how to do that, especially for something so trivial!).

#4 @nacin
5 years ago

  • Milestone changed from Awaiting Review to 3.1

#5 @nacin
5 years ago

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

(In [16542]) Cast term_id to int for queried_object_id. props wojtek.szkutnik, fixes #14590.

#6 @scribu
5 years ago

(In [16543]) Minor cleanup in queried object setting logic. See #14590

#7 @scribu
5 years ago

(In [16544]) Remove debug cruft from [16543]. See #14590

Note: See TracTickets for help on using tickets.