Opened 19 months ago
Last modified 2 months ago
#57749 new enhancement
In REST APIs, only prime meta data if there are registered keys
Reported by: | spacedmonkey | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | REST API | Keywords: | has-patch has-unit-tests has-testing-info |
Focuses: | rest-api, performance | Cc: |
Description
For REST API controllers like post, term, comment, this use Query classes like WP_Query, WP_Term_Query and WP_Comment_Query under the hood. By default of these query classes, also prime related meta data. This means that when a user requests one of these endpoints, meta data is primed along with the main object. However, this meta data may not be used in anywhere, making this priming unnessary. Meta data should only be primed, if there are registered meta keys that are going to be used.
Change History (3)
This ticket was mentioned in PR #7024 on WordPress/wordpress-develop by @antonvlasenko.
2 months ago
#1
- Keywords has-patch has-unit-tests added
#2
@
2 months ago
- Keywords has-testing-info added
I've submitted a PR that should address the issue described in this Trac ticket.
Steps to test:
- Review the code: Check the changes for correctness and adherence to coding standards.
- Run unit tests: Ensure all GitHub CI test jobs pass successfully.
- Test API endpoints: Make REST API requests to the following endpoints and verify you receive valid responses:
/wp/v2/comments
/wp/v2/posts
/wp/v2/categories
/wp/v2/tags
Since this PR focuses on optimization without introducing new functionality, creating more specific testing steps is challenging.
@antonvlasenko commented on PR #7024:
2 months ago
#3
Are these changes sufficient? Are there other areas that need optimization? If so, this PR can serve as the first step, with follow-up PRs to address additional improvements. Alternatively, I can modify this PR to include more endpoints if necessary.
Trac ticket: https://core.trac.wordpress.org/ticket/57749