[wp-trac] [WordPress Trac] #62500: REST API: Terms controller doesn't respect taxonomy's default query args
WordPress Trac
noreply at wordpress.org
Thu Nov 21 10:53:04 UTC 2024
#62500: REST API: Terms controller doesn't respect taxonomy's default query args
-----------------------------+---------------------
Reporter: Bernhard Reiter | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.8
Component: REST API | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses:
-----------------------------+---------------------
Comment (by Bernhard Reiter):
The controller's `get_items()` method has [https://github.com/WordPress
/wordpress-develop/blob/193f6eb26e65216576a10492dd4103044c3a079c/src/wp-
includes/rest-api/endpoints/class-wp-rest-terms-controller.php#L320-L327
two code branches]:
1. If a post ID is given in the network request, `get_items()` uses
[https://developer.wordpress.org/reference/functions/wp_get_object_terms/
`wp_get_object_terms()`] to get the terms associated with the given post.
That function includes [https://github.com/WordPress/wordpress-
develop/blob/654475fa25c88a2fecf9290ffcd9512b553a8574/src/wp-
includes/taxonomy.php#L2292-L2310 code] to respect the default query
`args` specified when the taxonomy was registered.
2. If no post ID is given, it uses
[https://developer.wordpress.org/reference/functions/get_terms/
`get_terms()`], which does not respect the default query args.
For the practical impact, more background, and a fix in the GB repo, see
https://github.com/WordPress/gutenberg/issues/65052 and
https://github.com/WordPress/gutenberg/pull/67154.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62500#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list