WordPress.org

Make WordPress Core

Opened 5 months ago

Last modified 2 weeks ago

#48105 new enhancement

Move Site Health async checks to a REST API endpoint

Reported by: Clorith Owned by:
Milestone: 5.5 Priority: normal
Severity: normal Version: 5.2
Component: Site Health Keywords: has-patch
Focuses: rest-api Cc:

Description

Currently various tests are ran asyncronously with a call to admin-ajax.php, which has some limitations, specifically in core filters not being loaded when using old style ajax calls (see the loopback to wp-admin/site-health.php?health-check-test-wp_version_check to verify the existence of the wp_version_check filter).

Moving things out into REST API endpoints would provide more flexibility, and better handling of permission checks as well. It also means that any code extending tests and adding their own async checks would have a much ore robust platform to test against, if they choose to utilize it.

There's some backwards compatibility considerations to be kept in mind, the current implementation of calling an admin-ajax call needs to be maintained, likely by introducing a has_rest => true flag to the async test registration to decide where to forward the call.

Attachments (2)

48105.patch (12.5 KB) - added by Clorith 5 months ago.
48105.2.patch (20.4 KB) - added by Clorith 2 months ago.

Download all attachments as: .zip

Change History (11)

@Clorith
5 months ago

#1 @Clorith
5 months ago

48105.patch is a first iteration of the above, it retains backwards compatibility for async tests created with admin-ajax.php in mind, but switches to using a REST endpoint if has_rest is defined and set to true.

It also adds failure handling to the async tests, so that if a test fails, it shouldn't break the JS from continuing with the next available check.

There's still some cleaning needed before this is ready (removing references to the old ajax hooks)

@Clorith
2 months ago

#2 @Clorith
2 months ago

  • Keywords has-patch added
  • Milestone changed from Future Release to 5.4

48105.2.patch provides REST endpoints for the previous ajax calls for the core provided asynchronous Site Health tests.

It also removed the now unused ajax handlers, and provides deprecation notices, and _doing_it_wrong calls to the callback functions from those ajax calls. I don't believe anyone is calling those functions directly, but better safe than sorry, as the saying goes.

It also improves on the failure handling for those tests, if a test fails, a notice will now be displayed in the recommended section, the badge has the label Unavailable, with a red outline, as opposed to the normal blue used by core for all other tests.

The URL invoked to perform the test is provided, and either the string No details available (as a fallback), or the error returned by the site.

#3 @TimothyBlynJacobs
7 weeks ago

I think this would be a great time to take a look at using a dashboard/v1 namespace for these dashboard endpoints that aren't modeling WP data objects. https://github.com/WP-API/proposals/pull/1

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


6 weeks ago

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


6 weeks ago

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


5 weeks ago

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


4 weeks ago

This ticket was mentioned in Slack in #core-site-health by clorith. View the logs.


3 weeks ago

#9 @Clorith
2 weeks ago

  • Milestone changed from 5.4 to 5.5

Bumping this to the 5.5. milestone, there's still discussions happening in relation to namespaces on the REST API, which I don't think it's realistic there will be a decision on before beta-1 for 5.4, and this enhancement is nice to have, but not critical.

Note: See TracTickets for help on using tickets.