Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#35382 closed defect (bug) (fixed)

get_terms with set fields 'id=>parent' not return the id key

Reported by: fantasyworld's profile fantasyworld Owned by: boonebgorges's profile boonebgorges
Milestone: 4.5 Priority: normal
Severity: normal Version: 2.7.1
Component: Taxonomy Keywords: good-first-bug has-patch
Focuses: Cc:

Description (last modified by dd32)

when use the id=>parent with number and fields in id=>name or and other id=>xx type.
In same case if the query return $terms array items in bigger then the number in you set with call the function.
It use the

array_slice( $terms, $offset, $number );

to cat the array into number you want
But this cat action will let the array id reset to 0, 1, 2 ... NOT the id of the term
may use the

array_slice( $terms, $offset, $number, true );

to keep the old id in the new array

Attachments (1)

35382.patch (481 bytes) - added by wpdelighter 9 years ago.

Download all attachments as: .zip

Change History (5)

#1 @dd32
9 years ago

  • Description modified (diff)
  • Keywords needs-patch good-first-bug added
  • Version changed from 4.4.1 to 2.7.1

Introduced with [10416]

9 years ago

#2 @wpdelighter
9 years ago

  • Keywords has-patch added; needs-patch removed

#3 @boonebgorges
9 years ago

  • Milestone changed from Awaiting Review to 4.5

#4 @boonebgorges
9 years ago

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

In 36252:

Don't reset index keys when trimming results of term queries.

array_slice() must be told to preserve keys when the query results exceed the
limit specified the 'number' parameter, so that id=>parent and other
id-indexed return value formats don't get mangled.

Props fantasyworld, wpdelighter.
Fixes #35382.

Note: See TracTickets for help on using tickets.