Abilities API: Add cached Site Health summary to core/get-environment-info#11834
Conversation
…alth summary. - Abilities: Added optional `fields` input parameter to `core/get-environment-info` to allow for response filtering. - Abilities: Introduced `site_health` output field providing status, issue counts, and a bounded list of actionable issues. - Site Health: Modified `WP_Site_Health::wp_cron_scheduled_check` to store critical/recommended issue details in the `health-check-site-status-result` transient. - Site Health: Updated `site-health.js` to ensure the issues list is transmitted during manual AJAX updates for cache parity.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Hi @KarunyaChavan! 👋 Thank you for your contribution to WordPress! 💖 It looks like this is your first pull request to No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making. More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook. Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook. If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook. The Developer Hub also documents the various coding standards that are followed:
Thank you, |
…o-core/get-environment-info
core/get-environment-info with cached Site Health datacore/get-environment-info
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Trac Ticket: https://core.trac.wordpress.org/ticket/65232
This PR extends
core/get-environment-infowith two additive changes:fieldsinput parameter, matching the response filtering behavior already used bycore/get-site-info.site_healthoutput field with a high-level Site Health summary for agents and other consumers of the Abilities API.The Site Health summary is read from the existing
health-check-site-status-resulttransient. The ability does not run Site Health tests, call Site Health test discovery, or trigger synchronous evaluation. If cached data is missing or malformed, the ability returnsstatus: "unknown"with empty counts and issues.flowchart LR A[Site Health checks run from UI or scheduled check] --> B[Normalize counts and actionable issues] B --> C[Store health-check-site-status-result transient] D[core/get-environment-info] --> E[Read transient only] E --> F[Return site_health summary]The
site_healthresponse includes:status:unknown,good,recommended, orcritical.counts: cached Site Health result counts forgood,recommended, andcritical.issues: up to 10 actionablerecommendedorcriticalissue summaries.truncated: whether more than 10 actionable issues were available.timestamp: Unix timestamp for when the cached Site Health data was collected, or0when no cached data exists.Example:
{ "site_health": { "status": "recommended", "counts": { "good": 12, "recommended": 3, "critical": 0 }, "issues": [ { "test": "background_updates", "label": "Background updates are not working as expected.", "severity": "recommended", "recommendation": "Contact your hosting provider to ensure WP-Cron can run." } ], "truncated": false, "timestamp": 1715714399 } }Cache Behavior
The Site Health transient is expanded to include normalized actionable issue summaries and a timestamp while preserving the existing aggregate counts used by the dashboard and admin menu.
flowchart TD A[Site Health result] --> B{Status} B -->|good| C[Increment good count] B -->|recommended| D[Increment recommended count] B -->|critical| E[Increment critical count] D --> F[Store normalized issue summary] E --> F C --> G[Do not include in issues array] F --> H[Save transient with timestamp] G --> HOnly actionable
recommendedandcriticalentries are stored in theissueslist. Passinggoodchecks remain represented incounts.good.The Site Health screen AJAX persistence path also sanitizes incoming issue summaries and preserves previous issue details only when the new counts still indicate actionable issues. This avoids carrying stale issue details after the site becomes clean.
Schema Changes
The output schema now documents the
site_healthobject and all nested properties with titles and descriptions. It also constrains known values with enums and disallows unexpected nested properties where appropriate.This makes the response clearer for adapters by documenting:
unknownandgood.recommendedorcritical.timestampcommunicates the freshness of cached Site Health data.Use of AI Tools
AI assistance: Yes
Tool(s): Codex
Model(s): GPT-5
Used for: refactoring and test coverage suggestions.