Skip to content

Secrets API: Let secrets.php set its overrides as plain variables - #15745

Closed
ericmann wants to merge 1 commit into
WordPress:trunkfrom
ericmann:secrets-dropin-globals
Closed

ericmann wants to merge 1 commit into
WordPress:trunkfrom
ericmann:secrets-dropin-globals

Conversation

@ericmann

@ericmann ericmann commented Nov 6, 2026

Copy link
Copy Markdown

wp_load_secrets_dropin() requires wp-content/secrets.php inside a function. A drop-in that sets its override as a plain variable, such as $wp_secrets_keyring = new My_Keyring();, sets a local variable. The override is ignored, and the default keyring protects the secrets instead, with nothing to say so. Raised by jorbin on #66187 comment:45.

The three globals are now declared before the require, as require_wp_db() does for db.php. Drop-ins that write to $GLOBALS[...] work as before.

The declaration only runs when a drop-in exists, so sites without one get no new globals.

Testing

The drop-in loads once, during bootstrap, so this has no unit test. I checked it with a src/wp-content/secrets.php that assigns $wp_secrets_keyring to an anonymous keyring class, and a test asserting that the key manager uses that keyring:

Keyring in use
trunk the default (derived from LOGGED_IN_KEY and LOGGED_IN_SALT)
this PR the drop-in's
  • --group secrets: 381 tests, no failures.
  • PHPCS is clean on load.php.

Trac ticket: https://core.trac.wordpress.org/ticket/66187

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Making the change, running the check above and the tests, and drafting this description. I reviewed the change and the results.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

`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.
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props ericmann.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 65395
GitHub commit: 0b25c19

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Nov 10, 2026
@peterwilsoncc

Copy link
Copy Markdown
Contributor

Merged r65378 / 8034f20

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.

2 participants