-
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
Add preload paths for autosaves #15067
Conversation
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.
Prior to this I had opened #15061 for a similar need. It's since been merged. There are now conflicts here, though I think it should be simple enough to follow the same pattern.
Filter out any duplicate endpoints
2040c3c
to
fcaa7bf
Compare
fcaa7bf
to
1d4fda5
Compare
@aduth - now rebased. Merging the changes wasn't too bad, the tests were a bit trickier, but I've managed to work it out. |
*/ | ||
function test_localizes_script() { | ||
$preload_paths = gutenberg_extend_block_editor_preload_paths( array() ); | ||
$post = (object) array( |
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.
Is this variable (and in the test below) unused?
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.
Yep, I made a mistake leaving that there after discovering that I could use the post factory in the test. Thanks for pointing it out.
lib/client-assets.php
Outdated
* the minimum supported version. | ||
*/ | ||
$post_type_object = get_post_type_object( $post->post_type ); | ||
$rest_base = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name; |
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.
While it seems unlikely given the filter flow, it makes me nervous to see null
as a possible return type of get_post_type_object
and then to have unguarded object property references. Should we be more guarded (wrap this whole bit in an if ( ! is_null( $post_type_object ) ) {
)?
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.
👍 good idea, I've addressed that.
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 looks like we need to commit this patch as well https://core.trac.wordpress.org/ticket/46974 for WP 5.3 |
Description
Adds a preload path for autosaves to help optimize the changes made in #7945.
Note there is a trac ticket that replicates this functionality in core (https://core.trac.wordpress.org/ticket/46974). In the meantime this should bring the same optimization to the plugin.
How has this been tested?
With this change: no requests to the autosaves endpoint are made when reloading the editor.
Without this change: a request is made to the autosaves endpoint when reloading the editor.
Types of changes
New feature (non-breaking change which adds functionality)
Checklist: