Make WordPress Core

Changeset 40078 for branches/4.7


Ignore:
Timestamp:
02/19/2017 03:18:38 AM (8 years ago)
Author:
rachelbaker
Message:

REST API: Cast revision author ID to int.

The post_author field is a string internally, but we need to cast it to an integer in the REST API. This was already done for posts, but not for revisions. The field is already declared as an integer in both controllers.

Props jnylen0.
Merges [40063] to the 4.7 branch.
Fixes #39871.

Location:
branches/4.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php

    r39957 r40078  
    345345
    346346        if ( ! empty( $schema['properties']['author'] ) ) {
    347             $data['author'] = $post->post_author;
     347            $data['author'] = (int) $post->post_author;
    348348        }
    349349
  • branches/4.7/tests/phpunit/tests/rest-api/rest-revisions-controller.php

    r39126 r40078  
    2828        ) );
    2929
     30        wp_set_current_user( self::$editor_id );
    3031        wp_update_post( array( 'post_content' => 'This content is better.', 'ID' => self::$post_id ) );
    3132        wp_update_post( array( 'post_content' => 'This content is marvelous.', 'ID' => self::$post_id ) );
     33        wp_set_current_user( 0 );
    3234    }
    3335
     
    137139        $data = $response->get_data();
    138140        $this->assertEqualSets( $fields, array_keys( $data ) );
     141        $this->assertSame( self::$editor_id, $data['author'] );
    139142    }
    140143
Note: See TracChangeset for help on using the changeset viewer.