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. git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40078 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c6511562c6
commit
7be9593b68
@ -344,7 +344,7 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller {
|
|||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
if ( ! empty( $schema['properties']['author'] ) ) {
|
if ( ! empty( $schema['properties']['author'] ) ) {
|
||||||
$data['author'] = $post->post_author;
|
$data['author'] = (int) $post->post_author;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty( $schema['properties']['date'] ) ) {
|
if ( ! empty( $schema['properties']['date'] ) ) {
|
||||||
|
@ -27,8 +27,10 @@ class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase
|
|||||||
'role' => 'contributor',
|
'role' => 'contributor',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
|
wp_set_current_user( self::$editor_id );
|
||||||
wp_update_post( array( 'post_content' => 'This content is better.', 'ID' => self::$post_id ) );
|
wp_update_post( array( 'post_content' => 'This content is better.', 'ID' => self::$post_id ) );
|
||||||
wp_update_post( array( 'post_content' => 'This content is marvelous.', 'ID' => self::$post_id ) );
|
wp_update_post( array( 'post_content' => 'This content is marvelous.', 'ID' => self::$post_id ) );
|
||||||
|
wp_set_current_user( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function wpTearDownAfterClass() {
|
public static function wpTearDownAfterClass() {
|
||||||
@ -136,6 +138,7 @@ class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase
|
|||||||
);
|
);
|
||||||
$data = $response->get_data();
|
$data = $response->get_data();
|
||||||
$this->assertEqualSets( $fields, array_keys( $data ) );
|
$this->assertEqualSets( $fields, array_keys( $data ) );
|
||||||
|
$this->assertSame( self::$editor_id, $data['author'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_get_item_embed_context() {
|
public function test_get_item_embed_context() {
|
||||||
|
Loading…
Reference in New Issue
Block a user