Skip to content

Improve Site Health check for plans without Redis - #96

Merged
jazzsequence merged 17 commits into
mainfrom
95-conditional-redis-test
Aug 8, 2025
Merged

Improve Site Health check for plans without Redis#96
jazzsequence merged 17 commits into
mainfrom
95-conditional-redis-test

Conversation

@jazzsequence

@jazzsequence jazzsequence commented Jul 23, 2025

Copy link
Copy Markdown
Contributor

Enhance the Site Health page to not display any report if user is on a Basic plan where Redis is unavailable, reducing confusion for users.

This implementation relies on headers sent by GCDN. If the headers are not present at all, the tests fail gracefully and do not run sit health tests at all.

Included in this implementation is some code that originally was written for Edge Integrations that allows us to pull the HTTP headers out of the $_SERVER superglobal and pluck the value of specific headers. Providing this function in the mu-plugin can be helpful for our future selves or customers building things similar to EI.

Tests have been added to verify this behavior and refine existing tests for compatibility with the new checks.

This PR also bumps the version of the Pantheon WP Coding Standards and applies fixes for the new rules added in 3.0.

fixes #95

Previously, the Site Health check for the Redis Object Cache would show a
'critical' error if the `CACHE_HOST` was not defined. This was confusing
for users on Basic plans where Redis is intentionally unavailable.

This change checks the service level. If the plan is one where Redis is
not available (e.g., 'basic'), the Site Health tool now displays a
'good' status with an informational message. This message explains that
Redis is not included in their plan and suggests upgrading.

This provides a better user experience and avoids unnecessary critical
warnings for users on these plans.
Adds a new test case to verify that the object cache health check correctly reports a 'good' status for plans (e.g., Basic) that do not include Redis.

Existing tests are updated to explicitly run under a 'performance' plan context to ensure they test for Redis availability as intended, isolating the new test case.
Use `unset()` instead of setting the environment variable to `null` to
more accurately reflect a missing `CACHE_HOST` variable.

The `assertContains()` method is less brittle when messages change
@jazzsequence
jazzsequence requested review from a team as code owners July 23, 2025 21:20
@jazzsequence jazzsequence self-assigned this Jul 23, 2025
Comment thread .github/workflows/test.yml
Introduces the `_pantheon_get_request_headers` function to retrieve and normalize HTTP request headers from the `$_SERVER` superglobal.

This utility standardizes header keys from the `HTTP_*` format (e.g., `HTTP_USER_AGENT`) to the standard HTTP header format (e.g., `User-Agent`), making them easier to work with in subsequent code.
This commit introduces the `_pantheon_get_header` function to provide a convenient way to access a single request header value.
The Redis object cache test previously displayed a "good" status on plans where Redis is not available (e.g. Basic plans). This was confusing as it reported on a feature that could not be used.

This change modifies the test to return early and not register itself in this scenario. This prevents the test from appearing in the Site Health screen, providing a cleaner and more accurate user experience.
we no longer report good or bad if we're on basic or headers are missing entirely
Comment thread inc/site-health.php
Comment thread inc/site-health.php Outdated
Comment thread inc/site-health.php
@jazzsequence
jazzsequence merged commit 89c651d into main Aug 8, 2025
15 checks passed
@jazzsequence
jazzsequence deleted the 95-conditional-redis-test branch August 8, 2025 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Site Health page recommends Redis when it's not available

3 participants