Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#39871 closed defect (bug) (fixed)

REST API: Revision author ID is returned as a string

Reported by: jnylen0 Owned by: jnylen0
Priority: normal Milestone: 4.7.3
Component: REST API Version: 4.7
Severity: normal Keywords: has-patch has-unit-tests fixed-major
Cc: Focuses:

Description

Apparently post_author is a string in the WP internals, "for compatibility reasons".

In WP_REST_Posts_Controller we cast it to an integer before returning it in the response.

In WP_REST_Revisions_Controller we don't do the corresponding cast.

The result is that the author ID is returned as a string, even though it is documented as an integer for both posts and revisions.

Attachments (1)

39871.diff​ (1.7 KB ) - added by jnylen0 10 years ago.

Download all attachments as: .zip

Change History (4)

@jnylen0
10 years ago

#1 @jnylen0
10 years ago

  • Owner set to jnylen0
  • Resolution → fixed
  • Status new → closed

In 40063:

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.

Fixes #39871.

#2 @jnylen0
10 years ago

  • Keywords fixed-major added
  • Resolution fixed
  • Status closed → reopened

Reopening for backport to 4.7 branch.

#3 @rachelbaker
10 years ago

  • Resolution → fixed
  • Status reopened → closed

In 40078:

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.

Note: See TracTickets for help on using tickets.