Repository navigation
[6.x] Build term associations once when warming the Stache - #15872
Merged
jasonvarga merged 1 commit intoNov 12, 2026
Merged
Conversation
The other term indexes read the associations, so the first of them to be updated built the associations when they weren't cached yet, and then the associations index built them again when it was updated itself. Update the associations first so they're built once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 tasks done
bpmore
pushed a commit
to UAMS-Web/uams-statamic
that referenced
this pull request
Nov 26, 2026
Closes #1250. Moves to `uams-web/patches-statamic-cms` `v1.2.0`, the release that drops the seven Stache vanished-file patches because `statamic/cms` `v6.43.0` carries their fix ([statamic/cms#15903](statamic/cms#15903)). Following the ticket's Scope ruling, three packages move and nothing else. ## Release adopted `v1.2.0`, not the latest `v1.4.0`. `v1.2.0` is the release that retires these seven patches. `v1.3.0` (the updates-badge retirement) belongs to #1261, and `v1.4.0` (the stale file items patch) belongs to #1509; per the ruling, each lands after the previous one merges. ## Lock changes Read from `composer.lock` against `main`: | Package | From | To | Why | | --- | --- | --- | --- | | `uams-web/patches-statamic-cms` | `v1.1.0` | `v1.2.0` | the release that drops the seven patches | | `statamic/cms` | `v6.40.0` | `v6.43.1` | `v1.2.0` requires `6.43.1` exactly | | `uams-web/aether-wordpress-importer` | `v0.34.0` | `v0.37.0` | `v0.34.0` requires `statamic/cms` `6.40.0` exactly; `v0.37.0` is the first release that allows `6.43.1` (scope widened on the ticket) | No other package changes version or reference. `phpstan/phpstan` `2.3.7` gains a `published-time` metadata field from the re-resolve; its version and reference are unchanged. `composer.json` raises the `statamic/cms` pin to `6.43.1` and the package floor to `^1.2`. Command: `composer update uams-web/patches-statamic-cms statamic/cms uams-web/aether-wordpress-importer --with uams-web/patches-statamic-cms:1.2.0 --with uams-web/aether-wordpress-importer:0.37.0`, then `composer patches-relock`, `composer update --lock` and `composer reinstall statamic/cms`. The first install failed, as expected, on the stale `patches.lock.json` entry for `statamic-stache-traverser-vanished-file.patch`; the relock fixed it. ## Patches `patches.lock.json` now lists four `statamic/cms` patches, in the package's order: collection create label, taxonomy create label, updates-overview badge, blueprint namespace slash. On reinstall all four apply, and `ensure-patches-applied.php` reports `all 22 checked patch(es) are applied in vendor/`. ## Tests kept, not deleted [`TraverserVanishedFileTest.php`](https://github.com/UAMS-Web/uams-statamic/blob/1250-patches-statamic-cms-v1.2.0/tests/Feature/Stache/TraverserVanishedFileTest.php) and [`StoreVanishedFileTest.php`](https://github.com/UAMS-Web/uams-statamic/blob/1250-patches-statamic-cms-v1.2.0/tests/Feature/Stache/StoreVanishedFileTest.php) run real race windows rather than checking for patch text, so they stay as tests of the upstream behavior. Their docblocks now say so. Upstream's `Traverser::traverse()` `catch` matches the retired patch: skip only when a fresh `scandir()` no longer lists the file, and rethrow otherwise. On stock `6.43.1`, 16 of the 18 cases passed unchanged. The two "still raises" controls failed with no exception thrown. `6.43.1` iterates Finder lazily instead of calling `sortByName()` first, so Finder stats each file just before the filter runs, and `getMTime()` was answered from PHP's stat cache without reaching the failing stream wrapper. Each control now calls `clearstatcache()` after setting up the failure. Mutation-checked by hand against the vendored `Traverser`, with the file restored byte-identical afterwards: - With the rethrow condition replaced by `if (false)`, the two "still raises" controls fail. - With the `continue` replaced by `throw $e`, the two "skips a file removed" cases fail. ## Removed or annotated - [`patches/README.md`](https://github.com/UAMS-Web/uams-statamic/blob/1250-patches-statamic-cms-v1.2.0/patches/README.md): the two guard-table rows for the retired patches. - [`docs/DECISIONS.md`](https://github.com/UAMS-Web/uams-statamic/blob/1250-patches-statamic-cms-v1.2.0/docs/DECISIONS.md): the 2026-09-29 traverser entry and the 2026-09-30 store entry each get a **Retired** note; neither entry is deleted. - `git grep statamic-stache-traverser-vanished-file`, excluding `docs/DECISIONS.md` and `composer.lock`, returns 0 hits; in `docs/DECISIONS.md` it returns 2, the annotated entry. `vanished-file` appears 0 times in `composer.lock` and `patches.lock.json`. ## `statamic/cms` changes between `6.40.0` and `6.43.1` The release notes for `v6.41.0` to `v6.43.0` change a lot of Stache internals: faster traversal and cold entry builds (statamic/cms#15821, statamic/cms#15826), blueprint and fieldset YAML kept between requests (statamic/cms#15813), term associations built once on warm (statamic/cms#15872), duplicate ids kept across clear and warm (statamic/cms#15883), and which indexes are used kept across a clear (statamic/cms#15897). Nothing in them is marked breaking. The full suite on the three-OS CI matrix is the check for this repository's Stache-backed code. ## Test plan - [x] `composer validate --no-check-publish --no-check-all` passes - [x] Pint `--test` on the changed tests passes - [x] `composer stan`: no errors - [x] cspell on the changed Markdown and PHP files: 0 issues - [x] `check-mutate-ignore-breadth` and `check-parallel-safe-tests` pass - [x] `php artisan test --compact tests/Feature/Stache/TraverserVanishedFileTest.php tests/Feature/Stache/StoreVanishedFileTest.php`: 18 passed, run as two invocations (6 + 12; the store suite was 12 of the first run's 16 passes) - [x] Remote CI green on Linux, Windows and macOS (head `9172bc421`; the macOS shard 3 job passed on re-run after a `TableSetPartialTest` failure that does not reproduce alone) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a terms store is warmed, each of its indexes is updated in turn:
id,path,slug,associations,site, and so on. The value indexes (idfirst) read the taxonomy'sassociationsindex to find the terms that only exist because entries use them. Since nothing is cached yet during a cold warm,idbuilding its items made the associations index build itself. Then the warm reachedassociationsand built it again.Building the associations queries every collection that uses the taxonomy and loads each entry that has a value for it, so on a site with lots of entries this was the most expensive index in the store, and it ran twice per taxonomy.
TaxonomyTermsStorenow putsassociationsfirst in its indexes, so the warm builds the associations before anything reads them. The value indexes then read them from the cache instead of building them. Nothing else depends on the order of the indexes; the other places that use them (clear(),sync(),resolveIndexes()) go by name.TermAssociationsWarmingTestcounts the entry queries made while the terms store warms. Before this change it sees two per taxonomy; now it sees one.Benchmark
stache:warmfrom a cleared cache, alternating between6.x(7097691) and this branch 4 times so both see the same machine conditions. Each run is a fresh PHP process; medians shown (Apple Silicon, PHP 8.4). The site is generated: dated articles with 1–5 tags (skewed usage) and a category each, plus a structured pages collection. Tags are N/50 (min 50), and there are 12 categories.6.xThe branch was faster in all 8 pairs. Per index at 10,000 articles,
terms::tags/iddrops from 1.10s to 0.71s andterms::categories/idfrom 0.53s to 0.23s.This is separate from #15871, which makes the term value indexes cheaper to build. The two don't depend on each other.
🤖 Generated with Claude Code