From 0883535f4b32974b0224b6f26eaafd0e0f112abd Mon Sep 17 00:00:00 2001 From: Eric Mann Date: Fri, 6 Nov 2026 08:54:38 -0800 Subject: [PATCH] Secrets API: Let secrets.php set its overrides as plain variables. `wp_load_secrets_dropin()` requires the drop-in inside a function, so a drop-in that assigned `$wp_secrets_keyring = new My_Keyring();` set a local variable. The override was ignored, and secrets were protected by the default keyring instead, with nothing to say so. The three globals are now declared before the require, as `require_wp_db()` does for db.php. See #66187. --- src/wp-includes/load.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php index 31f82524bab85..4cd2b4467c001 100644 --- a/src/wp-includes/load.php +++ b/src/wp-includes/load.php @@ -831,6 +831,10 @@ function wp_using_ext_object_cache( $using = null ) { * Runs once, before must-use plugins load, so that every interface a drop-in's * classes implement already exists and every plugin sees the drop-in's provider. * + * The drop-in sets its overrides in the `$wp_secrets_provider`, `$wp_secrets_store` + * and `$wp_secrets_keyring` globals. They are declared global before the require, so + * a plain assignment such as `$wp_secrets_keyring = new My_Keyring();` works. + * * Sets `$GLOBALS['wp_secrets_dropin_loaded']` as soon as the file is found, whether * or not it then loads cleanly: wp_using_secrets_dropin() reports presence, not * health. @@ -873,6 +877,12 @@ function wp_load_secrets_dropin(): void { $GLOBALS['wp_secrets_dropin_loaded'] = true; + /* + * The drop-in is required inside this function. Declaring the overrides global + * lets it set them as plain variables, as db.php does with $wpdb. + */ + global $wp_secrets_provider, $wp_secrets_store, $wp_secrets_keyring; + try { require $dropin_path; } catch ( Throwable $e ) {