- Status: Accepted
- Date: 2026-10-22
- Related: ADR 0002
To propagate a fix, the merge needs three inputs: the pattern before the fix (the base), the pattern now, and each copy in the content. The base is what lets us tell "the fix changed this" from "an editor changed this".
Version 0.1.0 kept its own history to supply the base:
- On every
admin_init, it hashed every registered pattern and stored new versions in thehm_pattern_sync_snapshotsoption. - Updated copies were stamped with
metadata.patternVersion. - For unstamped copies, every known version was tried and the one with the smallest "design distance" to the copy was used as the base.
It worked, but it cost more than it bought:
| Cost | Measured / observed |
|---|---|
| Option size | ~500 KB on a Twenty Twenty-Five child theme. It stored all 100 parent theme patterns, none of them ours. |
| Admin overhead | Every wp-admin request loaded every pattern file to hash it (~30 ms). |
| Hidden state | The result depended on which versions happened to be captured, and when. Hard to explain and to reproduce. |
| Code | ~280 lines (Snapshots class, distance heuristic, status and snapshot commands). |
The case it solved is a copy that missed one or more fixes (nobody ran the command between fix N and fix N+1). With the command run as part of shipping each fix, that case doesn't happen.
Patterns live in the theme, and the theme is in git. Git already is the version history.
Remove the plugin's own history. wp pattern-sync update requires the base
explicitly:
--from-file=<path>reads a file. This is the production path (see the 2026-10-26 update below), and also covers patterns not registered from a file.--from-ref=<git ref>reads the pattern file at that ref (usuallyHEAD~1). Handy locally, where the theme's git history exists.
patternVersion is no longer written. patternName is still written on
updated copies, so copies found by --fingerprint become exact matches.
- No option, no hooks on admin requests, about 280 fewer lines.
- The result of a run is fully determined by its arguments.
- Run the command once per fix, as part of shipping it. If a fix is
skipped, the next run treats the old design on those copies as an editor
customisation and leaves it alone (silently, unless the same value changed
again, which is a conflict). To catch up, run with
--from-refpointing at the version those copies have, for example once per missed commit, in order. patternVersionalready written by 0.1.0 is left in content. It's harmless. (0.1.0 was never installed outside our test sites, so there's no clean-up code for its option.)
Our hosts (VIP, Altis, Pantheon) deploy code without the theme's git history,
and WP-CLI runs there remotely (vip wp …, terminus wp …). --from-ref
can't work where the content lives.
Decision: the previous version ships with the fix, as a file in the theme.
wp pattern-sync prepare # locally, before committing the fix
vip wp pattern-sync update --apply # on the server, after the deploy
preparewrites the committed version of every changed pattern file to<theme>/pattern-sync/<name>.previous.phpand stages it.updatewith no arguments handles every pattern that has a base there (the pattern name comes from the base's ownSlug:header).- Still no hidden history: the base is a versioned file, visible in the PR, and only fixed patterns get one. Nothing happens on activation.
- It lives outside
patterns/, so WordPress doesn't register it as a pattern. --from-fileand--from-refstay, for other setups and local use.- Cost:
prepareis one step to remember per fix (a PR checklist item). A pre-commit hook could run it, at the cost of installing it per project; not worth it unless the step gets forgotten.
- People need to start a propagation from wp-admin (today the screen only takes decisions; ADR 0003). They don't have git, so the screen would have to record the base at the moment someone clicks "propagate" (the pattern markup before the fix, only for that pattern). That's simpler and cheaper than the 0.1.0 automatic capture.
- Patterns stop living in a git repo (e.g. patterns edited in the database by non-developers). A base would then have to be captured when the pattern is saved.
- Missed fixes become a real problem in practice. In that case, bring back
patternVersionstamping only, plus the list of bases passed on the command line, not automatic capture.