Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
464115d
Site Health: Cache the full results and a timestamp in the status tra…
gziolo Jun 15, 2026
4eac8ca
Tests: Fix Site Health AJAX tests on multisite
gziolo Jun 15, 2026
2f40735
Fix PHPStan `argument.type` error for mixed being passed to `json_enc…
westonruter Jun 15, 2026
1bbc163
Fix PHPStan `argument.type` error for `wp_unslash()` expecting `array…
westonruter Jun 15, 2026
f3a5c6a
Simply accessing counts
westonruter Jun 15, 2026
8e4e45a
Add void return type hints
westonruter Jun 15, 2026
cfdd9be
Update dispatch_result_request method to always return array
westonruter Jun 15, 2026
68c44fd
Use native property type hint
westonruter Jun 15, 2026
1bf29ea
fixup! Update dispatch_result_request method to always return array
westonruter Jun 15, 2026
226f710
Fix PHPStan issues in tests
westonruter Jun 15, 2026
c9e97d4
Site Health: Cache the full results in a dedicated, non-autoloaded tr…
gziolo Jun 16, 2026
5262865
Apply suggestions from code review
gziolo Jun 22, 2026
04a3420
Site Health: Refine the detail cache types and parameter naming.
gziolo Jun 22, 2026
d520f50
Site Health: Seed the JS results array from PHP.
gziolo Jun 23, 2026
0d2e61a
Site Health: Cache only locale-independent result data.
gziolo Jun 23, 2026
9146969
Site Health: Reduce duplication in the status cache accessors.
gziolo Jun 23, 2026
d00a7e0
Add type definition for tests
westonruter Jul 9, 2026
dbc8be8
Fix return type of get_instance() method
westonruter Jul 9, 2026
692d480
Specify shape of $counts param for set_site_status_counts
westonruter Jul 9, 2026
ac4e14e
Add array type for $counts param for normalize_status_counts()
westonruter Jul 9, 2026
b3c9efe
Reformat return array shape
westonruter Jul 9, 2026
644d07a
Factor out array shape into reusable type
westonruter Jul 9, 2026
5435d45
Reduce specificity of pre-normalized types
westonruter Jul 9, 2026
3713084
Eliminate redundnat type guards when reading from cache
westonruter Jul 9, 2026
a52cbe4
Leverage JSON schema for validation and use object for results instea…
westonruter Jul 10, 2026
5992833
Refactor handling of test results
westonruter Jul 10, 2026
8bc9979
Fix error when saving transient with identical value
westonruter Jul 10, 2026
94be08a
Fix ajax tests
westonruter Jul 10, 2026
518531f
Site Health: Compute detailed status counts at runtime
gziolo Jul 24, 2026
1875dd4
Site Health: Specialize the detailed status cache reader
gziolo Jul 24, 2026
728c227
Site Health: Fix storing test results in JavaScript
gziolo Jul 24, 2026
c4a295d
Site Health: Clarify detailed result documentation
gziolo Jul 24, 2026
1862d04
Site Health: Validate scheduled test results
gziolo Jul 24, 2026
2954322
Site Health: Compare detail cache with correct transient
gziolo Jul 24, 2026
661e87e
Site Health: Ignore results without test identifiers
gziolo Jul 24, 2026
58079e3
Site Health: Clarify detail result validation
gziolo Jul 24, 2026
02dfa09
Site Health: Return first AJAX save error
gziolo Jul 24, 2026
5bcbea0
Site Health: Require detailed status timestamps
gziolo Jul 24, 2026
d4824e0
Site Health: Store freshest verified results
gziolo Jul 24, 2026
a711928
Site Health: Add status cache error messages
gziolo Jul 24, 2026
1a0d531
Site Health: Document the distinct roles of both status caches.
gziolo Oct 30, 2026
9715326
Site Health: Remove redundant async test type check.
gziolo Oct 30, 2026
24baaa5
Site Health: Consolidate status counts and verified results in one ca…
gziolo Oct 30, 2026
2a46549
Site Health: Limit stored status results and target 7.3.0.
gziolo Oct 30, 2026
d3e2cf0
Site Health: Make status cache tests work with an object cache.
gziolo Oct 30, 2026
cc46473
Site Health: Move the status cache autoload check to its own test.
gziolo Oct 30, 2026
af708b4
Site Health: Reject unsupported statuses and string results in the ca…
gziolo Oct 30, 2026
7e7e486
Site Health: Clarify that the result limit does not bound cache bytes.
gziolo Oct 30, 2026
e9d307b
Site Health: Simplify cache initialization and clarify eviction order…
gziolo Oct 30, 2026
8a4f63d
Site Health: Derive displayed counts from cached results.
gziolo Nov 2, 2026
0083902
Site Health: Reject blank test identifiers before caching results.
gziolo Nov 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions src/js/_enqueues/admin/site-health.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ jQuery( function( $ ) {
return false;
}

/*
* Only these statuses have a section on the screen and are accepted by the
* server-side cache. Any other status would make the whole cache update fail.
*/
if ( -1 === [ 'good', 'recommended', 'critical' ].indexOf( issue.status ) ) {
return false;
}

// A blank identifier would cause the server to reject the entire cache update.
if ( 'string' !== typeof issue.test || '' === issue.test.trim() ) {
return false;
}

// Loop over expected data and match the data types.
for ( key in minimumExpected ) {
value = minimumExpected[ key ];
Expand Down Expand Up @@ -160,10 +173,14 @@ jQuery( function( $ ) {

count = SiteHealth.site_status.issues[ issue.status ];

// If no test name is supplied, append a placeholder for markup references.
if ( typeof issue.test === 'undefined' ) {
issue.test = issue.status + count;
}
/*
* Collect the test name and status so they can be cached server-side. These
* include the asynchronous tests that only run in the browser. Labels are left
* out on purpose, as they are translated and the cache is shared across locales.
*/
SiteHealth.site_status.results[ issue.test ] = {
status: issue.status
};
Comment thread
gziolo marked this conversation as resolved.
Resolved
Comment thread
gziolo marked this conversation as resolved.
Resolved

if ( 'critical' === issue.status ) {
heading = sprintf(
Expand Down Expand Up @@ -254,12 +271,14 @@ jQuery( function( $ ) {
}

if ( isStatusTab ) {
// One request avoids competing counts-only and results-only updates to the shared cache.
$.post(
ajaxurl,
{
'action': 'health-check-site-status-result',
'_wpnonce': SiteHealth.nonce.site_status_result,
'counts': SiteHealth.site_status.issues
'counts': SiteHealth.site_status.issues,
'results': JSON.stringify( SiteHealth.site_status.results )
}
);

Expand Down
43 changes: 42 additions & 1 deletion src/wp-admin/includes/ajax-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5448,7 +5448,14 @@ function wp_ajax_health_check_loopback_requests() {
/**
* Handles site health check to update the result status via AJAX.
*
* Counts and compact per-test results are saved together. Counts-only requests
* remain supported for compatibility, and results-only requests preserve stored counts.
* Core readers calculate counts from valid, unexpired per-test results when available;
* the stored counts remain for consumers that read the transient directly.
*
* @since 5.2.0
* @since 7.3.0 The submitted counts are validated, and optional per-test statuses
* and timestamps extend the existing transient.
*/
function wp_ajax_health_check_site_status_result() {
check_ajax_referer( 'health-check-site-status-result' );
Expand All @@ -5457,7 +5464,41 @@ function wp_ajax_health_check_site_status_result() {
wp_send_json_error();
}

set_transient( 'health-check-site-status-result', wp_json_encode( $_POST['counts'] ) );
if ( ! class_exists( 'WP_Site_Health' ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
}

$counts = null;
$results = null;

if ( isset( $_POST['counts'] ) ) {
if ( ! is_array( $_POST['counts'] ) ) {
wp_send_json_error();
}
$counts = wp_unslash( $_POST['counts'] );
}

if ( isset( $_POST['results'] ) ) {
if ( ! is_string( $_POST['results'] ) ) {
wp_send_json_error();
}
$results = json_decode( wp_unslash( $_POST['results'] ), true );
Comment thread
gziolo marked this conversation as resolved.
Resolved
if ( ! is_array( $results ) ) {
wp_send_json_error();
}
}

if ( null !== $results ) {
$saved = WP_Site_Health::update_site_status_detail( $results, $counts );
} elseif ( null !== $counts ) {
$saved = WP_Site_Health::set_site_status_counts( $counts );
} else {
wp_send_json_error();
}

if ( is_wp_error( $saved ) ) {
wp_send_json_error( $saved );
}

wp_send_json_success();
}
Expand Down
Loading
Loading