Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 26 additions & 9 deletions cli/class-wp-cli-secret-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,17 +649,34 @@ public function generate_key(): void {
* @param array<string, string|bool> $assoc_args Associative arguments.
*/
public function health( array $args, array $assoc_args ): void {
// Core loads its Site Health tests only for the Site Health screen, so on a
// WordPress that ships the API they are not loaded under WP-CLI.
if ( ! function_exists( 'wp_secrets_site_health_test_key_source' ) ) {
require_once ABSPATH . 'wp-admin/includes/secrets-site-health.php';
if ( class_exists( 'Secrets_API_Site_Health', false ) ) {
// Before 7.2, the plugin's copies of core's tests.
$site_health = new Secrets_API_Site_Health();
} else {
// Core loads WP_Site_Health only for the Site Health screen, so it is not
// loaded under WP-CLI.
if ( ! class_exists( 'WP_Site_Health', false ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
}

$site_health = WP_Site_Health::get_instance();
}

$results = array(
wp_secrets_site_health_test_key_source(),
wp_secrets_site_health_test_undecryptable(),
wp_secrets_site_health_test_needs_rotation(),
);
if ( method_exists( $site_health, 'get_test_secrets_api_key_source' ) ) {
$results = array(
$site_health->get_test_secrets_api_key_source(),
$site_health->get_test_secrets_api_undecryptable(),
$site_health->get_test_secrets_api_needs_rotation(),
);
} else {
// The 7.2 betas before r65394 have the tests as functions, which
// class-wp-site-health.php loads. Remove once 7.2 is released.
$results = array(
wp_secrets_site_health_test_key_source(),
wp_secrets_site_health_test_undecryptable(),
wp_secrets_site_health_test_needs_rotation(),
);
}

$items = array();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ exactly the release the commit message promised them for.
nothing else.** It loads none of `src/` or `plugin/`. The commands call the public API and the
internals core has as well (`_wp_secrets_get_key_manager()`, `_wp_secrets_get_provider()`,
`_wp_secrets_get_store()`, `WP_Secrets_Config_Key_Provider`), so the same `cli/` runs on core's
implementation unchanged. `wp secret health` loads core's
`wp-admin/includes/secrets-site-health.php` itself, since core loads it only for the Site Health
screen.
implementation unchanged. `wp secret health` loads core's `WP_Site_Health` itself, since core
loads it only for the Site Health screen. (When this was decided, the tests were functions in
`wp-admin/includes/secrets-site-health.php`. [r65394](https://core.trac.wordpress.org/changeset/65394)
made them methods of `WP_Site_Health`.)

**`migrate-legacy` does not come along.** The prototype was deprecated and its users told to
migrate more than a month before 7.2. The migrator and legacy reader load only with the plugin's
Expand Down
7 changes: 5 additions & 2 deletions docs/reference/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ make ci # all of the above, except test-stand-down

`make test-stand-down` needs a WordPress that ships the Secrets API, such as trunk, so it is not
part of `make ci`. It runs the `stand-down` group with `SECRETS_API_TESTS_EXPECT_CORE=1`, which
makes the stand-down tests fail instead of skip on a WordPress without the API.
makes the stand-down tests fail instead of skip on a WordPress without the API. The group also
holds the Site Health parity tests: `plugin/class-secrets-api-site-health.php` copies methods
from core's `WP_Site_Health` and `WP_Debug_Data` for WordPress before 7.2, and on trunk each copy
is compared with core's. When one fails, copy the method again from core.

## The always-works path

Expand Down Expand Up @@ -132,7 +135,7 @@ person pasted.
|---|---|---|---|
| `static` | 8.3 | — | lint + compat + analyse. Gates everything else. |
| `test` | 7.4, 8.0, 8.3, 8.5; 7.4 | 7.1.x; 6.8 | Single site |
| `stand-down` | 7.4, 8.5 | trunk | `make test-stand-down`: core serves the API, and the plugin loads none of its own layer. Core is wordpress-develop trunk's `src/`, from the same tarball as the test suite, not the nightly zip, which can lag a day behind it. |
| `stand-down` | 7.4, 8.5 | trunk | `make test-stand-down`: core serves the API, the plugin loads none of its own layer, and the plugin's copies of core's Site Health methods match core's. Core is wordpress-develop trunk's `src/`, from the same tarball as the test suite, not the nightly zip, which can lag a day behind it. |
| `test-multisite` | 8.3 | 7.1.x | Multisite suite |
| `smoke` | 7.4, 8.3, 8.5; 8.3 | 7.1.x; nightly | WP-CLI end to end, single site then multisite. The nightly leg runs the commands on core's implementation. |
| `examples` | 8.3 | 7.1.x | `make test-examples` against Moto (an AWS emulator) and a Vault dev server, both pinned by digest, single site then multisite. Not part of `make ci`. |
Expand Down
97 changes: 97 additions & 0 deletions docs/reference/classes.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

165 changes: 0 additions & 165 deletions docs/reference/functions.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions docs/spec/rotation.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ reached through the CLI.

**Flagging for rotation.** Every slot carries `needs_rotation`. `wp_import_option_as_secret()`
sets it to `true`; ordinary writes set `false`. It surfaces in `wp_list_secrets()`, in the Site
Health test `secrets_api_needs_rotation` in `src/wp-admin/includes/secrets-site-health.php`, and
in `wp secret health`.
Health test `secrets_api_needs_rotation`, and in `wp secret health`.

## Why

Expand Down
18 changes: 10 additions & 8 deletions docs/spec/scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ scope", and "Timeline" in the [proposal][proposal].
`Requires PHP: 7.4`.

**Core-bound versus plugin-only.** Everything under `src/` is written to be copied into
`wordpress-develop` unchanged: `src/wp-includes/secrets.php` holds the public functions,
`src/wp-includes/secrets/` holds the classes, and
`src/wp-admin/includes/secrets-site-health.php` holds Site Health. `plugin/` and `cli/` are never
copied. `tests/phpunit/test-architecture.php` enforces the boundary: no reference to `WP_CLI`,
`wordpress-develop` unchanged: `src/wp-includes/secrets.php` holds the public functions, and
`src/wp-includes/secrets/` holds the classes. `plugin/` and `cli/` are never copied. `tests/phpunit/test-architecture.php` enforces the boundary: no reference to `WP_CLI`,
`plugin/`, or `cli/` under `src/`; no self-guarding `function_exists()` or `class_exists()`; every
file carries `@since 7.2.0`; no text domain passed to a translation function; no subdirectory other than the
three core paths; no prototype-compatibility symbol.
two core paths; no prototype-compatibility symbol.

**The core patch.** Trac ticket [#66187](https://core.trac.wordpress.org/ticket/66187), under
review in [WordPress/wordpress-develop#13759](https://github.com/WordPress/wordpress-develop/pull/13759).
Expand Down Expand Up @@ -67,9 +65,13 @@ defined and true. On a WordPress that ships the API they run on core's implement
`migrate-legacy` refuses, since its migrator loads only with the plugin's copy. Both are exercised
end to end against a real `wp` binary by `tests/smoke/smoke.sh`, on single site and multisite.

**Site Health.** Three tests (`secrets_api_key_source`, undecryptable secrets,
`secrets_api_needs_rotation`) and a debug-information section, in
`src/wp-admin/includes/secrets-site-health.php`.
**Site Health.** Three tests (`secrets_api_key_source`, `secrets_api_undecryptable`,
`secrets_api_needs_rotation`) and a debug-information section under the key `wp-secrets-api`. In
core they are methods of `WP_Site_Health` and `WP_Debug_Data`
([r65394](https://core.trac.wordpress.org/changeset/65394)). A plugin can't add methods to those
classes, so before 7.2 `plugin/class-secrets-api-site-health.php` registers copies of them through
the `site_status_tests` and `debug_information` filters. On trunk, a stand-down test compares each
copy with core's, so a core change that needs porting fails CI.

**No UI.** There is no settings screen, no options page, and no admin menu entry.

Expand Down
Loading
Loading