Make WordPress Core

Ticket #21397: patch-core-21397-2.diff

File patch-core-21397-2.diff, 3.8 KB (added by koke, 12 years ago)
  • wp-includes/class-wp-xmlrpc-server.php

    diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php
    index 300f5f5..0945d5b 100644
    a b class wp_xmlrpc_server extends IXR_Server { 
    7878                        'wp.getPostFormats'     => 'this:wp_getPostFormats',
    7979                        'wp.getPostType'                => 'this:wp_getPostType',
    8080                        'wp.getPostTypes'               => 'this:wp_getPostTypes',
     81                        'wp.getRevisions'               => 'this:wp_getRevisions',
     82                        'wp.restoreRevision'    => 'this:wp_restoreRevision',
    8183
    8284                        // Blogger API
    8385                        'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
    class wp_xmlrpc_server extends IXR_Server { 
    12041206
    12051207                $post = get_post( $post_id, ARRAY_A );
    12061208
     1209    if ( isset( $content_struct['only_if_no_new_revision'] ) ) {
     1210      // if there's a newer revision, return an error
     1211      if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['only_if_no_new_revision']->getTimestamp() ) {
     1212        return new IXR_Error( 409, __( 'There is a revision of this post that is more recent' ) );
     1213      }
     1214    }
     1215
    12071216                if ( empty( $post['ID'] ) )
    12081217                        return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    12091218
    class wp_xmlrpc_server extends IXR_Server { 
    31713180                return $struct;
    31723181        }
    31733182
     3183        /**
     3184         * Retrieve revisions for a specific post.
     3185         *
     3186         * @since 3.5.0
     3187         *
     3188         * The optional $fields parameter specifies what fields will be included
     3189         * in the response array.
     3190         *
     3191         * @uses wp_get_post_revisions()
     3192         * @see wp_getPost() for more on $fields
     3193         *
     3194         * @param array $args Method parameters. Contains:
     3195         *  - int     $blog_id
     3196         *  - string  $username
     3197         *  - string  $password
     3198         *  - int     $post_id
     3199         *  - array   $fields
     3200         * @return array contains a collection of posts.
     3201         */
     3202        function wp_getRevisions( $args ) {
     3203                if ( ! $this->minimum_args( $args, 4 ) )
     3204                        return $this->error;
     3205                $this->escape( $args );
     3206
     3207                $blog_id    = (int) $args[0];
     3208                $username   = $args[1];
     3209                $password   = $args[2];
     3210                $post_id    = (int) $args[3];
     3211
     3212                if ( isset( $args[4] ) )
     3213                        $fields = $args[4];
     3214                else
     3215                        $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post' ), 'wp.getRevisions' );
     3216
     3217                if ( ! $user = $this->login( $username, $password ) )
     3218                        return $this->error;
     3219
     3220                do_action( 'xmlrpc_call', 'wp.getRevisions' );
     3221
     3222                $posts_list = wp_get_post_revisions( $post_id );
     3223
     3224                if ( ! $posts_list )
     3225                        return array();
     3226
     3227                // holds all the posts data
     3228                $struct = array();
     3229
     3230                foreach ( $posts_list as $post ) {
     3231                        $struct[] = $this->_prepare_post( get_object_vars( $post ), $fields );
     3232                }
     3233
     3234                return $struct;
     3235        }
     3236
     3237        /**
     3238         * Restore a post revision
     3239         *
     3240         * @since 3.5.0
     3241         *
     3242         * The optional $fields parameter specifies what fields will be included
     3243         * in the response array.
     3244         *
     3245         * @uses wp_restore_post_revision()
     3246         * @see wp_getPost() for more on $fields
     3247         *
     3248         * @param array $args Method parameters. Contains:
     3249         *  - int     $blog_id
     3250         *  - string  $username
     3251         *  - string  $password
     3252         *  - int     $post_id
     3253         *  - array   $fields
     3254         * @return bool false if there was an error restoring, true if success.
     3255         */
     3256        function wp_restoreRevision( $args ) {
     3257                if ( ! $this->minimum_args( $args, 3 ) )
     3258                        return $this->error;
     3259
     3260                $this->escape( $args );
     3261
     3262                $blog_id    = (int) $args[0];
     3263                $username   = $args[1];
     3264                $password   = $args[2];
     3265                $post_id    = (int) $args[3];
     3266
     3267                if ( isset( $args[4] ) )
     3268                        $fields = $args[4];
     3269                else
     3270                        $fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post' ), 'wp.restoreRevisions' );
     3271
     3272                if ( ! $user = $this->login( $username, $password ) )
     3273                        return $this->error;
     3274
     3275                do_action( 'xmlrpc_call', 'wp.restoreRevision' );
     3276
     3277                $post = wp_restore_post_revision( $post_id, $fields );
     3278
     3279                return true;
     3280        }
     3281
    31743282        /* Blogger API functions.
    31753283         * specs on http://plant.blogger.com/api and http://groups.yahoo.com/group/bloggerDev/
    31763284         */