WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 2 weeks ago

#36271 new enhancement

Trigger _doing_it_wrong if wp_send_json is used on a REST API request

Reported by: rmccue Owned by:
Milestone: 5.5 Priority: normal
Severity: normal Version: 4.4
Component: REST API Keywords: has-patch
Focuses: Cc:

Description

We should heavily discourage users from using wp_send_json (& co.) on REST API requests. Two changes I want to make:

  1. If _doing_it_wrong is triggered on a REST request, we should add a header ala the _deprecated_function headers.
  2. If wp_send_json is called on a REST request, we should trigger a _doing_it_wrong and point people towards WP_REST_Response and WP_Error

Change History (6)

#1 @rachelbaker
4 years ago

  • Keywords has-unit-tests added
  • Milestone changed from Awaiting Review to Future Release

Moved into Future Release, needs a patch.

#2 @TimothyBlynJacobs
6 weeks ago

  • Keywords good-first-bug added
  • Milestone set to 5.5
  • Version set to 4.4

I still see this occurring in the wild. Milestoning for 5.5.

#3 @johnbillion
5 weeks ago

  • Keywords has-unit-tests good-first-bug removed

This ticket was mentioned in PR #325 on WordPress/wordpress-develop by TimothyBJacobs.


4 weeks ago

  • Keywords has-patch added; needs-patch removed

This ticket was mentioned in Slack in #core-restapi by timothybjacobs. View the logs.


3 weeks ago

#6 @TimothyBlynJacobs
2 weeks ago

@SergeyBiryukov could you take a look at this one if you have a chance?

Note: See TracTickets for help on using tickets.