Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page list: Use fields param for get_pages() #64624

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

rafaelgallani
Copy link
Contributor

@rafaelgallani rafaelgallani commented Aug 19, 2024

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 to WP_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.

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`.
Copy link

github-actions bot commented Aug 19, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: rafaelgallani <rafaelgalani@git.wordpress.org>
Co-authored-by: carolinan <poena@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@rafaelgallani rafaelgallani added the [Type] Performance Related to performance efforts label Aug 19, 2024
@t-hamano t-hamano added the [Block] Page List Affects the Page List Block label Aug 20, 2024
@carolinan
Copy link
Contributor

Wont this break for plugins that filters get_pages()?

@rafaelgallani
Copy link
Contributor Author

rafaelgallani commented Aug 20, 2024

@carolinan , thanks for the review! Why would that be? Sorry, I don't get it. Are there any specific get_posts() hooks? I couldn't find any for it in the docs. I just realized you mentioned get_pages() instead of get_posts(). Sorry. That's true... 🤔
Hmm. But I still think we could benefit from the fields specified in the query. I'll try some other changes and update the PR.

@rafaelgallani rafaelgallani changed the title Page list: Replace get_pages() with get_posts() Page list: Use fields param for get_pages() Aug 21, 2024
@rafaelgallani rafaelgallani added the [Status] In Progress Tracking issues with work in progress label Aug 21, 2024
@rafaelgallani rafaelgallani marked this pull request as draft August 21, 2024 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Page List Affects the Page List Block [Status] In Progress Tracking issues with work in progress [Type] Performance Related to performance efforts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants