[wp-trac] [WordPress Trac] #45933: WSODs protection returns incorrect content type for JSON Requests

WordPress Trac noreply at wordpress.org
Sun Jan 20 13:03:19 UTC 2019

#45933: WSODs protection returns incorrect content type for JSON Requests
 Reporter:  spacedmonkey                        |       Owner:  flixos90
     Type:  defect (bug)                        |      Status:  reviewing
 Priority:  normal                              |   Milestone:  5.1
Component:  Bootstrap/Load                      |     Version:  trunk
 Severity:  normal                              |  Resolution:
 Keywords:  servehappy needs-testing has-patch  |     Focuses:  multisite
Changes (by flixos90):

 * keywords:  servehappy needs-patch needs-testing => servehappy needs-
     testing has-patch


 [attachment:"45933.2.diff"] is a modification of
 [attachment:"45933.10.diff"] that makes the following changes:

 * Make `_wp_die_process_input()` more predictable and aligned with other
 functions: You pass in `$message`, `$title`, and `$args`, and you get back
 `$message`, `$title`, and `$args`.
 * Move all input data processing into the new function so that the
 handlers really only need to worry about the output. For example, the
 `wp_parse_args()` call and default values for arguments like
 `text_direction` are now handled there as well (note that
 `_ajax_wp_die_handler()` still contains its own call to ensure the
 "irregular" default of a 200 response code). The handler itself is then
 free to choose which of that information to render.
 * Ensure that additional errors each contain their code, message, and data
 rather than only their message.
 * Ensure that JSON output is formatted coherently with REST API errors,
 with a `data` key including `status` instead of `status` in the root.

 This way it is ensured that the function calling `wp_die()` does not need
 to know what kind of request is currently being made. Regardless of
 how/which arguments are passed, they will just work.

Ticket URL: <https://core.trac.wordpress.org/ticket/45933#comment:34>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list