Page list: Use fields param for get_pages()#64624
Page list: Use fields param for get_pages()#64624rafaelgallani wants to merge 2 commits intotrunkfrom
fields param for get_pages()#64624Conversation
So we can defer caching to `WP_Query` and specify the fields returned in the query. This breaks for sites that have pages with many data on their `post_content`.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Wont this break for plugins that filters get_pages()? |
|
@carolinan |
get_pages() with get_posts()fields param for get_pages()
What?
Specify the fields used in the query so the page list component doesn't break for pages with a very large content.
Why?
get_pages()always selects all fields (*) - and some data isn't used when rendering the block. This breaks sites that have pages with extensive content.We could use a direct query, but caching wouldn't be implemented. By specifying the
fieldsparam, we can specify the list of fields used in the component, andcaching gets deferred toWP_Query.Testing Instructions
For a site with very large content on its pages, try to load/use/add the navigation block and ensure it loads correctly. It's somewhat difficult to reproduce because sometimes - in a local environment - you can meet other limits (OOM, request failing because OOM, etc), so it's more like an optimization to be able to render the block/cache the results properly so it can be used.