[wp-trac] [WordPress Trac] #63256: Unnecessary array_map() call in get_terms() when object_ids is not set
WordPress Trac
noreply at wordpress.org
Mon Oct 27 08:30:50 UTC 2025
#63256: Unnecessary array_map() call in get_terms() when object_ids is not set
-------------------------------------------------+-------------------------
Reporter: dilipbheda | Owner: audrasjb
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: 6.9
Component: Taxonomy | Version:
Severity: normal | Resolution:
Keywords: has-patch needs-testing needs-unit- | Focuses:
tests |
-------------------------------------------------+-------------------------
Comment (by staurand):
@westonruter
We are overiding {{{ "$this->query_vars['object_ids']" }}} later in the
code (that was what the patch changed).
So we may check earlier if the param is valid then re-use the logic in the
two places where we need it.
{{{
Index: src/wp-includes/class-wp-term-query.php
===================================================================
--- src/wp-includes/class-wp-term-query.php (revision 61066)
+++ src/wp-includes/class-wp-term-query.php (working copy)
@@ -439,9 +439,11 @@
}
}
+ $is_object_ids_param_valid = ! empty(
$this->query_vars['object_ids'] ) || is_numeric(
$this->query_vars['object_ids'] );
+
// 'term_order' is a legal sort order only when joining
the relationship table.
$_orderby = $this->query_vars['orderby'];
- if ( 'term_order' === $_orderby && empty(
$this->query_vars['object_ids'] ) ) {
+ if ( 'term_order' === $_orderby && !
$is_object_ids_param_valid ) {
$_orderby = 'term_id';
}
@@ -590,7 +592,7 @@
);
}
- if ( '' === $args['object_ids'] ) {
+ if ( ! $is_object_ids_param_valid ) {
$args['object_ids'] = array();
} else {
$args['object_ids'] = array_map( 'intval', (array)
$args['object_ids'] );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63256#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list