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
Prevent network requests related to ephemeral posts in the widgets editor #25899
Conversation
|
Size Change: +10.4 kB (0%) Total Size: 1.19 MB
ℹ️ View Unchanged
|
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 wonder if we can do better than plopping
if ( nextOptions?.responseBody ) {
return nextOptions.responseBody;
}
like that. Seems random :)
Otherwise the idea to have a way to stop apiFetch via middleware is a good idea.
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.
It's definitely a nicer hack, but it's still a hack 🙂
I'm happy with it for 5.6. Would prefer that we don't add responseBody though and instead just don't call next().
packages/edit-widgets/src/components/edit-widgets-initializer/index.js
Outdated
Show resolved
Hide resolved
|
Yes I vote for @noisysocks idea and also call the option something that indicates that apiFetch won't request anything. Setting responseBody is weird :) |
It is still a hack indeed, multi-entity saving/editing would be the real answer here - let's explore it after 5.6 :-) |
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 think this is a good fix, albeit not the complete solution, to the problem we have.
Description
This PR follows up the discussion from #25831:
The approach taken here is different. Instead of adding a new concept to
core-data, this PR simply plugs intoapi-fetchand prevents any unwanted requests from happening. While the implementation differs, the approach is inspired by Drupal's api-fetch.The advantage of this approach over the current approach is that it's resilient. It doesn't require any initialization, it doesn't rely on implementation details of the resolution pipeline (such as faking
startResolutionandendResolution), it won't be easily broken by updates tocore-data. The only hardcoded part is the path string, I'd rather not use the one specified indefaultEntities -> baseURLas the data structure there is just another implementation detail of the resolution system.The same treatment could be applied to the navigation editor which also uses an in-memory post as a convenience wrapper.
How has this been tested?
widget-arearelated network error logged.Types of changes
Non-breaking change
Checklist: