[6.x] Avoid loading the revisions store when finding a working copy#14847
Merged
Conversation
Finding a single working copy went through the query builder, which forced the entire revisions Stache store to load. A working copy is one file at a deterministic path, so read it directly. This avoids warming the whole revisions store when entries are checked for working copies during warming. Co-Authored-By: Claude Opus 4.8 <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.
Summary
Resolving a single working copy via
Revisions::findWorkingCopyByKey()ran a query against the revisions Stache store:The first such call forces the revisions store's indexes to build, which loads every revision and working-copy file on the site into memory. A working copy is a single file at a deterministic path, so this reads it directly instead:
This restores the pre-#10437 behaviour for this lookup while keeping the query builder for actual revision queries (
whereKey(), CP revision history, etc.).Why
Entry::workingCopy()/hasWorkingCopy()are called per-entry during Stache warming — e.g. via computed fields, or anyvalues()call during URI index building. Before #10437 each call was a cheapfile_exists(); afterwards each call could trigger a full warm of the revisions store.On a real site (~3,600 entries in one collection, revisions enabled) this was the dominant cost of
stache:warm. Isolated cold-load of that collection:findWorkingCopyByKeyFixes #14842.
Testing
Added coverage to
tests/Revisions/RepositoryTest.php:nullwhen there's no working copy