[wp-trac] [WordPress Trac] #43316: REST API: Support autosaves

WordPress Trac noreply at wordpress.org
Sat Mar 10 21:55:10 UTC 2018


#43316: REST API: Support autosaves
-------------------------------------------------+-------------------------
 Reporter:  kraftbj                              |       Owner:
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  5.0
Component:  REST API                             |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-testing needs-unit-  |     Focuses:  rest-api
  tests                                          |
-------------------------------------------------+-------------------------

Comment (by azaozz):

 Replying to [comment:27 adamsilverstein]:
 [attachment:43316.4.diff] is looking good. Couple of things:

 1. Perhaps declare the constant at the beginning of `create_item()` to
 match current behavior. Also an ! if_defined() check is always good :)
 {{{
 if ( ! defined( 'DOING_AUTOSAVE' ) ) {
      define( 'DOING_AUTOSAVE', true );
 }
 }}}

 2.
 {{{
 // This bit
 if ( 'draft' === $parent->post_status ) { ...

 // needs to be
 if ( $post_author == $parent->post_author && ( 'auto-draft' ===
 $parent->post_status || 'draft' === $parent->post_status ) ) { ...
 }}}

 3. The `get_item()` should probably also account for `post_author`. See
 `get_autosave( $request )` in 43316.1.patch.

 4. There may be more than one autosave if several people have edited the
 post. Do we get all of them in `get_items()`? IMHO logically we should,
 need to loop through all revisions and pick only the autosaves.

 5. What are we going to return after updating the draft or saving or
 deleting an autosave, (when `create_item()` runs)? At the moment it's all
 over the place: WP_Error, or 0 or the autosave post or the updated draft.
 We need to pick one :) [[br]] [[br]] In the Slack chat the idea was to
 only return the ID, but that ID can be to the actual post, to the new or
 updated autosave revision, or 0 if the autosave revision was deleted so
 not sure. Or we can return either the post (when a draft was updated) or
 the autosave revision (when updated or created), or WP_Error (with
 appropriate error message) when error or the autosave was deleted.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/43316#comment:29>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list