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:
parent
23d545224c
commit
8ba137b739
|
@ -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'] );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue