Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#39871 closed defect (bug) (fixed)

REST API: Revision author ID is returned as a string

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

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 8 years ago.

Download all attachments as: .zip

Change History (4)

@jnylen0
8 years ago

#1 @jnylen0
8 years ago

  • Owner set to jnylen0
  • Resolution set to fixed
  • Status changed from new to 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
8 years ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for backport to 4.7 branch.

#3 @rachelbaker
8 years ago

  • Resolution set to fixed
  • Status changed from reopened to 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.