Skip to content

Secrets API: Make the provider, store and keyring abstract classes - #15744

Closed
ericmann wants to merge 3 commits into
WordPress:trunkfrom
ericmann:secrets-abstract-classes
Closed

ericmann wants to merge 3 commits into
WordPress:trunkfrom
ericmann:secrets-abstract-classes

Conversation

@ericmann

@ericmann ericmann commented Nov 6, 2026

Copy link
Copy Markdown

WP_Secrets_Provider, WP_Secrets_Store and WP_Secrets_Keyring are now abstract classes instead of interfaces, as jorbin suggested on #66187 comment:45.

Once 7.2 ships, adding a method to an interface is a fatal error in every drop-in that implements it, so the interfaces could never change. With abstract classes, a later release can add a method with a default implementation, and existing drop-ins keep working. Two such methods are already likely: a way for a provider or keyring to say whether it is usable (see wp_is_secrets_api_available() in #15258), and a key re-wrapping path for 7.3.

What changes

  • The three are abstract class with abstract public methods. The method signatures are unchanged.
  • The default and fail-closed implementations, the test mocks and the anonymous test classes use extends instead of implements.
  • The files are renamed from interface-wp-secrets-*.php to class-wp-secrets-*.php, and wp-settings.php loads them under the new names.
  • Docblocks that said "interface" now say "class", including the notes on wp_load_secrets_dropin().
  • A new test pins all three as abstract classes, so they can't quietly turn back into interfaces.

For drop-in authors, the change is implements → extends. A drop-in can no longer extend some other base class, but it can still wrap one.

Testing

  • --group secrets: 384 tests on single site and 392 on multisite, no failures (PHP 8.5, MySQL 8.4).
  • PHPCS is clean on the changed files.

This conflicts with #15200, which adds #[\SensitiveParameter] to wrap() and set() in the files renamed here. Whichever lands second needs a small rebase.

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, the test and this description, and running the tests. 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_Secrets_Provider`, `WP_Secrets_Store` and `WP_Secrets_Keyring` were
interfaces. Once 7.2 ships, adding a method to an interface is a fatal error in
every drop-in that implements it, so they could never change. As abstract
classes, a later release can add a method with a default implementation, and
existing drop-ins keep working.

Drop-ins now extend these classes. The method signatures are unchanged.

The files are renamed from `interface-wp-secrets-*.php` to
`class-wp-secrets-*.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, whyisjake.

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.

@whyisjake

Copy link
Copy Markdown
Member

@ericmann #15200 was committed in r65375, and this now conflicts with trunk, as you expected. Could you rebase it when you have a moment?

# Conflicts:
#	src/wp-includes/secrets/class-wp-secrets-keyring.php
#	src/wp-includes/secrets/class-wp-secrets-provider.php
@ericmann

Copy link
Copy Markdown
Author

@whyisjake Done: trunk is merged in at 511b568. The two conflicts were the #[\SensitiveParameter] signatures from r65375; both methods stay abstract and keep the attribute. --group secrets passes on single site and multisite.

@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
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