Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Return full post object when deleting post #1256

Merged
merged 3 commits into from
May 21, 2015
Merged

Return full post object when deleting post #1256

merged 3 commits into from
May 21, 2015

Conversation

danielbachhuber
Copy link
Member

See #1224

@danielbachhuber
Copy link
Member Author

@WP-API/amigos #reviewmerge

@rachelbaker
Copy link
Member

I would like @rmccue to weigh in here and in: #1255, #1254, and #1253

@rachelbaker
Copy link
Member

From the HTTP spec for DELETE:

A successful response SHOULD be 200 (OK) if the response includes an entity describing the status, 202 (Accepted) if the action has not yet been enacted, or 204 (No Content) if the action has been enacted but the response does not include an entity.

I don’t know what an entity describing the status means

@@ -327,6 +327,10 @@ public function delete_item( $request ) {
return new WP_Error( 'rest_user_cannot_delete_post', __( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => 401 ) );
}

$mock_request = new WP_REST_Request( 'GET', rest_url( 'wp/v2/' . $this->get_post_type_base( $this->post_type ) . '/' . $post->ID ) );
$mock_request->set_param( 'context', 'edit' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$mock_request isn't really the right name, since this is a real request and "mock" has a specific meaning. $get_request?

@rmccue
Copy link
Member

rmccue commented May 19, 2015

This generally looks OK to me. One thing we might want to consider is wrapping the post in another object (e.g. { data: {...}, trashed: true, gone: false }) to make it clear that the request did succeed (since we're meant to be describing the status), buuuuut that might be overkill.

@rmccue
Copy link
Member

rmccue commented May 19, 2015

Also, should we consider this from #627?

if ( $new_status === 'trash' ) {
    // Send a 202 if it's only trashed to indicate that it will be
    // actually deleted later
    $response->set_status( 202 );

i.e. 200 = permanently deleted, 202 = trashed

Not sure we need the distinction now with the split from double-DELETE to separate trash/perma-delete, but worth thinking about.

@danielbachhuber
Copy link
Member Author

Not sure we need the distinction now with the split from double-DELETE to separate trash/perma-delete, but worth thinking about.

See #1260

rmccue added a commit that referenced this pull request May 21, 2015
Return full post object when deleting post
@rmccue rmccue merged commit df7f00d into develop May 21, 2015
@rmccue rmccue deleted the 1224-return-post branch May 21, 2015 01:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants