Skip to content

Commit 2945fa6

Browse files
authored
Merge pull request #18 from ericmann/abstract-classes-adr
ADR 0017: Abstract classes for the extension points
2 parents 5f794f6 + 823ae38 commit 2945fa6

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: "ADR 0017: Abstract classes for the extension points"
3+
description: "WP_Secrets_Provider, WP_Secrets_Store and WP_Secrets_Keyring become abstract classes, so a later release can add a method without breaking every drop-in."
4+
---
5+
6+
# ADR 0017: Abstract classes for the extension points
7+
8+
| | |
9+
|---|---|
10+
| **Number** | 0017 |
11+
| **Date** | 2026-11-06 |
12+
| **Status** | Accepted |
13+
14+
## Context
15+
16+
The three extension points, `WP_Secrets_Provider`, `WP_Secrets_Store` and `WP_Secrets_Keyring`,
17+
were interfaces from 0.1.0 on ([ADR 0001](0001-provider-as-outermost-extension-point.md)).
18+
Reviewing the code in core, a committer pointed out on [#66187 comment:45][c45] that once 7.2
19+
ships, core can never add a method to them. A class that implements an interface without one of
20+
its methods is a fatal error, so every drop-in written against 7.2 would break.
21+
22+
There are already two methods we expect to want:
23+
24+
- A way for a provider or keyring to say whether it is usable. `wp_is_secrets_api_available()`,
25+
added in [PR 15258][pr15258] at a committer's request, can only answer that for the default
26+
keyring. For a drop-in it assumes yes.
27+
- A path to re-wrap the root key under a new site key, planned for 7.3, which may need a keyring
28+
method.
29+
30+
Interfaces were the first choice, and they are still the cleaner contract: a drop-in class can
31+
extend whatever it likes, and PHP checks the whole contract. The alternative to switching was to
32+
keep the interfaces and add every later capability as a separate, optional interface checked with
33+
`instanceof`. That keeps compatibility, but every new feature then needs a new type and a check at
34+
each call site.
35+
36+
## Decision
37+
38+
**The three become abstract classes.** Their methods become `abstract public`, with the same
39+
signatures. The default and fail-closed implementations `extend` them. The files are renamed from
40+
`interface-wp-secrets-*.php` to `class-wp-secrets-*.php`. Proposed in [PR 15744][pr15744].
41+
42+
**A later release adds methods with a default implementation.** That is the reason for the change,
43+
and the class docblocks say so.
44+
45+
**A test pins them as abstract classes**, so they can't become interfaces again by accident.
46+
47+
## Consequences
48+
49+
- A drop-in changes `implements` to `extends`. Nothing else in the contract changes. 7.2 has not
50+
shipped, so the only drop-ins affected are those written against the beta or this plugin.
51+
- A drop-in class can no longer extend another base class, such as an SDK client. It can still hold
52+
one and delegate to it, as the examples already do.
53+
- The conformance suites, `WP_Secrets_Provider_Conformance` and `WP_Secrets_Keyring_Conformance`,
54+
work as before.
55+
- `src/` follows core. The classes, the examples in `examples/`, and the pages that call these
56+
interfaces ([extension points](../spec/extension-points.md),
57+
[providers and keyrings](../spec/providers-and-keyrings.md)) change when the core patch is
58+
ported.
59+
60+
[c45]: https://core.trac.wordpress.org/ticket/66187#comment:45
61+
[pr15258]: https://github.com/WordPress/wordpress-develop/pull/15258
62+
[pr15744]: https://github.com/WordPress/wordpress-develop/pull/15744

0 commit comments

Comments
 (0)