Page list: Use fields
param for get_pages()
#64624
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
fields
param, 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.