Make WordPress Core

Opened 5 weeks ago

Last modified 5 weeks ago

#63256 reviewing defect (bug)

Unnecessary array_map() call in get_terms() when object_ids is not set

Reported by: dilipbheda's profile dilipbheda Owned by: audrasjb's profile audrasjb
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch
Focuses: Cc:

Description

The get_terms() function always triggers the else block because the result is cast to an array and sent to array_map(), even when object_ids isn't set. This is unnecessary since the default value of object_ids is null.

The default value here is null: https://github.com/WordPress/wordpress-develop/blob/ac648a15245df2261c0782f7e1c618911f392601/src/wp-includes/class-wp-term-query.php#L199C1-L199C4

The else block runs here: https://github.com/WordPress/wordpress-develop/blob/ac648a15245df2261c0782f7e1c618911f392601/src/wp-includes/class-wp-term-query.php#L596-L600

Change History (2)

This ticket was mentioned in PR #8668 on WordPress/wordpress-develop by @dilipbheda.


5 weeks ago
#1

#2 @audrasjb
5 weeks ago

  • Milestone changed from Awaiting Review to 6.9
  • Owner set to audrasjb
  • Status changed from new to reviewing

Makes sense, thanks.

Note: See TracTickets for help on using tickets.