-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Issue #13618 - only request three fields: id, title and parent to populate the Parent page select list #23637
Conversation
@@ -66,6 +66,7 @@ const applyWithSelect = withSelect( ( select ) => { | |||
parent_exclude: postId, | |||
orderby: 'menu_order', | |||
order: 'asc', | |||
_fields: 'id,title,parent', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something we tried but it's not a valid approach because the data module keeps a cache per id and if you do this and another component request the same entity but want access to the remaining properties, it will get a trimmed version causing issues. Basically whenever you use getEntityRecords
you shouldn't explicitly pass context
or fields
. This PR tried to solve it #19498 but it's more complex than it seems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that's a bit of a bummer. Why not prevent caching for requests where _fields
is used? And what should be done about context
which is already being passed as edit
. Or should the request use a completely different approach - such as an AJAX request that calls wp_dropdown_pages, which is what this code is trying to emulate after all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it's not great. Ideally, something like #19498 is pursued to completion and support multiple entities shapes in core-data.
I also think the unlimited API requests is one of the worst aspects of Gutenberg right now and it has other solutions: pagination and I believe @epiqueras and @adamsilverstein are also looking into this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the information returned for this _fields
request is not going to be useful elsewhere, would it be possible to store it as a different entity type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To land something like #19498, we would need to reinvent GraphQL, as can be seen from the caveats that led to the closing of the PR.
Can we use a direct API call in this component until pagination lands?
Now that #19498 is merged, I think we can move forward with this. I've rebased the PR @bobbingwide do you think you can check that everything is still working as expected? |
Hi @youknowriad. I'm sorry but I don't understand what you want me to do. I downloaded the latest version of Gutenberg but the new line of code's not there. Adding it again to the build showed that the solution works. Please advise. |
Can you review #12795 |
I was actually talking about testing the current PR. I just did so and it seems to work properly for me. |
As I said, I retested with the fix applied.
|
closes #13618
Description
This is a fix for the performance issue reported in #13618
The REST requests now pass the
_fields
parameter, requesting only 3 fields: id, title and parent.How has this been tested?
I tested the fix in my development environment where I reported the problem initially.
I measured the server response time of the requests using my oik-bwtrace plugin.
Here's the raw data.
Before:
After
From this raw data you can glean.
The detailed trace output shows which actions and filters were invoked.
For page 1 the total number was 367789 before. This reduced to 34319 after.
Before the change the
the_content
filter was called once for each page returned.Afterwards, it wasn't called at all. Nor, for that matter was
the_excerpt
.My testing environment is a local copy ( s.b/oikcom ) of a website called oik-plugins.com
The before and after tests summarised above were performed against pages - 373 published
I also ran the after tests against the oik-file CPT, which is also hierarchical, with 330 published posts.
server times were: 1.08, 0.86, 0.86 and 0.64
Screenshots
The Parent Page: select list is populated as before applying the fix.
The duplicate entries are still present. See #12795
The order doesn't match the order shown in Quick Edit either. But that's another issue... to be raised.
Types of changes
Performance improvement. On slow systems with complex page content it should prevent the user experiencing 500 error codes, mostly due to elapsed execution time being exceeded.
Checklist: