Make WordPress Core

Opened 6 years ago

Last modified 6 days ago

#49408 new enhancement

Why is the action wp_ajax_wp_link_ajax not using wp_send_json()

Reported by: stephanh Owned by:
Priority: normal Milestone: Awaiting Review
Component: General Version: 5.3.2
Severity: normal Keywords: has-patch needs-testing has-unit-tests
Cc: Focuses: coding-standards

Description

The action now returns an array with results with the header content-type text/html
Should this not be application/json as achieved by the wp_send_json() function?

https://core.trac.wordpress.org/browser/tags/5.3.2/src/wp-admin/includes/ajax-actions.php#L1863

Attachments (1)

49408.patch (382 bytes ) - added by stephanh 6 years ago.

Download all attachments as: .zip

Change History (4)

@stephanh
6 years ago

#1 @sabernhardt
6 years ago

  • Keywords has-patch added

#2 @sabernhardt
6 years ago

  • Keywords needs-testing added

This could use some testing by someone who understands it better than I do :)

Next time, please create a patch from the root directory, but 49408.patch does apply to src.

The code for the wp_ajax_wp_link_ajax was added in 3.1 (changeset:16459), and wp_send_json was created for 3.5. So that's likely why it is not used yet.

Version 0, edited 6 years ago by sabernhardt (next)

This ticket was mentioned in PR #12832 on WordPress/wordpress-develop by @arkaprabhachowdhury.


6 days ago
#3

  • Keywords has-unit-tests added

## Summary\n\n- Use wp_send_json() for wp_ajax_wp_link_ajax() responses.\n- Add regression coverage for the JSON content type and response payload.\n\nTrac: https://core.trac.wordpress.org/ticket/49408\n\n## Testing\n\n- PHPCBF\n- PHPCS\n- PHP syntax checks\n- PHPUnit blocked locally because the Docker MySQL host is unavailable.

Note: See TracTickets for help on using tickets.