XML-RPC: Add an if_not_modified_since argument to wp.editPost.

Accepts a GMT date, which is used to compare to the current post_modified_gmt
value for the post being edited. If the post has since been edited (as in, too
old of a date was passed), the edit is rejected as overwriting a newer version.

It is rejected with a HTTP 409 Conflict status code. (Fancy.)

props koke, markoheinjen.
Tests: [UT1049]

see #21397.



git-svn-id: https://develop.svn.wordpress.org/trunk@22034 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2012-09-27 03:39:40 +00:00
parent 23d545224c
commit 8ba137b739
1 changed files with 8 additions and 1 deletions

View File

@ -1258,6 +1258,13 @@ class wp_xmlrpc_server extends IXR_Server {
if ( empty( $post['ID'] ) ) if ( empty( $post['ID'] ) )
return new IXR_Error( 404, __( 'Invalid post ID.' ) ); return new IXR_Error( 404, __( 'Invalid post ID.' ) );
if ( isset( $content_struct['if_not_modified_since'] ) ) {
// If the post has been modified since the date provided, return an error.
if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) {
return new IXR_Error( 409, __( 'There is a revision of this post that is more recent.' ) );
}
}
// convert the date field back to IXR form // convert the date field back to IXR form
$post['post_date'] = $this->_convert_date( $post['post_date'] ); $post['post_date'] = $this->_convert_date( $post['post_date'] );