someday the rest check will work

This commit is contained in:
David Smith 2025-02-13 08:31:16 -06:00
parent bbbaa2ba56
commit 6bed85cca4
3 changed files with 25 additions and 1 deletions

View File

@ -136,6 +136,7 @@ $core_actions_post = array(
'wp-privacy-erase-personal-data',
'health-check-site-status-result',
'health-check-dotorg-communication',
'health-check-alt-update-api-communication',
'health-check-is-in-debug-mode',
'health-check-background-updates',
'health-check-loopback-requests',

View File

@ -301,6 +301,29 @@ class WP_Debug_Data {
'debug' => true
);
if ( WP_UPDATE_API_DEFAULT !== wp_get_update_api_base()) {
$wp_update_api = wp_remote_get( wp_get_update_api_base(), array( 'timeout' => 10 ) );
if ( ! is_wp_error( $wp_update_api ) ) {
$fields['alt_update_api_communication'] = array(
'label' => __( 'Communication with update API' ),
'value' => __( 'Update API is reachable.' ),
'debug' => 'true',
);
} else {
$fields['alt_update_api_communication'] = array(
'label' => __( 'Communication with update API' ),
'value' => sprintf(
/* TODO translator note */
__('Unable to reach %1$s: %2$s' ),
gethostbyname( parse_url( wp_get_update_api_base(), PHP_URL_HOST ) ),
$wp_update_api->get_error_message(),
),
'debug' => $wp_update_api->get_error_message(),
);
}
}
return array(
'label' => __( 'WordPress' ),
'fields' => $fields,

View File

@ -136,7 +136,7 @@ class WP_REST_Site_Health_Controller extends WP_REST_Controller {
'methods' => 'GET',
'callback' => array( $this, 'test_alt_update_api_communication' ),
'permission_callback' => function() {
return $this->validate_request_permission( 'dotorg_communication' );
return $this->validate_request_permission( 'alt_update_api_communication' );
},
),
'schema' => array( $this, 'get_public_item_schema' ),