WordPress.org

Make WordPress Core

Opened 4 months ago

Closed 4 months ago

#38817 closed defect (bug) (fixed)

REST API: Store the user_agent by default in the comments API

Reported by: dd32 Owned by: rachelbaker
Milestone: 4.7 Priority: normal
Severity: normal Version:
Component: Comments Keywords: has-patch has-unit-tests commit
Focuses: rest-api Cc:

Description

The comments API currently doesn't store the user_agent by default, unless the client specifies it.

As the user_agent field is a user-controllable field, I see no issue with allowing it to be set through the REST API parameters, however believe that it should default to $_SERVER['HTTP_USER_AGENT'] when not specified by the client.

Attachments (2)

38817.diff (1.6 KB) - added by dd32 4 months ago.
38817.2.diff (2.3 KB) - added by rachelbaker 4 months ago.
Added ! empty spacing and a unit test

Download all attachments as: .zip

Change History (5)

@dd32
4 months ago

#1 @jnylen0
4 months ago

  • Keywords needs-unit-tests added

Needs tests and missing an operator space: !empty! empty. Otherwise makes sense to me.

@rachelbaker
4 months ago

Added ! empty spacing and a unit test

#2 @rachelbaker
4 months ago

  • Keywords has-unit-tests commit added; needs-unit-tests removed

38817.2.diff Adds the space in the empty conditional and also includes a unit test.

#3 @rachelbaker
4 months ago

  • Owner set to rachelbaker
  • Resolution set to fixed
  • Status changed from new to closed

In 39287:

REST API: On comment create, fallback to the user_agent header value.

If a user-agent is not explicitly provided in the author_user_agent parameter, fallback to the user_agent value in the request header.

Props dd32, jnylen0, rachelbaker.
Fixes #38817.

Note: See TracTickets for help on using tickets.