-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Navigation: Only fetch wp_navigation menus once #49143
Conversation
Size Change: -4 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
Flaky tests detected in 81e9999. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4440160008
|
{ per_page: -1, status: [ 'publish', 'draft' ] }, | ||
{ per_page: -1, status: 'publish,draft' }, |
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.
@adamziel Do you have any idea why this might be the case? Seems like a bug in the underlying implementation of Core Data.
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 looked into what might be going on here. It doesn't seem to make a difference in the final query before the rest api WP_Query happens. The comma separated string gets transformed into an array before the WP_Query. This image shows the status array query vs string query end up being identical.
I dumped the $query_args with die()
after it if it was a navigation request to see the params here.
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 may be misunderstanding where to look test this at. I would add a new post, then add a navigation block to the page.
@@ -71,8 +71,9 @@ function selectNavigationMenus( select ) { | |||
const args = [ | |||
'postType', | |||
'wp_navigation', | |||
{ per_page: -1, status: [ 'publish', 'draft' ] }, | |||
{ per_page: -1, status: 'publish,draft' }, |
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.
@scruffian If we do this we will need a comment to explain why it has to be a string for now.
Well this is very strange. Looks like this also triggers a number of test failures so we'll need to get to the bottom of those as well. |
@scruffian, in which editor are you testing? This change shouldn't have any effect on request numbers. Looking at the requests in the Site Editor, we're making two for navigation. One is from Sidebar, and the Navigation block triggers the other. We can delay the first request once the suggestion from #48906 is implemented. The request triggered by the Navigation block is only critical for fallback logic. Can we try to trigger that request if the block has no Screenshot |
The Site Editor |
Sorry I must have been testing something incorrectly yesterday, this doesn't resolve anything. Closing. |
I think I found the issue this time: #49161 |
What?
As part of #48683 we noticed that there are two API requests being made for wp_navigation entities - one for published and draft statuses, and one for just draft statuses. This seems to be a feature of the way that
getEntityRecords
works whenstatus
is set to an array. If change it a string with the valuepublish,draft
then it does one request to get all wp_navigation entities.Why?
This saves one unnecessary API request. It should also simplify #48683.
How?
Change the status from an array to a string
Testing Instructions
navigation
/wp-json/wp/v2/navigation
/wp-json/wp/v2/navigation