WordPress.org

Make WordPress Core

Changeset 22034


Ignore:
Timestamp:
09/27/2012 03:39:40 AM (6 years ago)
Author:
nacin
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-xmlrpc-server.php

    r21959 r22034  
    12591259            return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    12601260
     1261        if ( isset( $content_struct['if_not_modified_since'] ) ) {
     1262            // If the post has been modified since the date provided, return an error.
     1263            if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) {
     1264                return new IXR_Error( 409, __( 'There is a revision of this post that is more recent.' ) );
     1265            }
     1266        }
     1267
    12611268        // convert the date field back to IXR form
    12621269        $post['post_date'] = $this->_convert_date( $post['post_date'] );
     
    14761483                $query['order'] = $filter['order'];
    14771484        }
    1478        
     1485
    14791486        if ( isset( $filter['s'] ) ) {
    14801487            $query['s'] = $filter['s'];
Note: See TracChangeset for help on using the changeset viewer.