Skip to content

[6.x] Prevent errors when Stache indexes contain keys without files - #15052

Merged
jasonvarga merged 2 commits into
6.xfrom
fix-stache-orphaned-index-keys
Jul 22, 2026
Merged

[6.x] Prevent errors when Stache indexes contain keys without files#15052
jasonvarga merged 2 commits into
6.xfrom
fix-stache-orphaned-index-keys

Conversation

@joshuablum

Copy link
Copy Markdown
Member

Queries against the Stache can fail with:

Call to a member function selectedQueryColumns() on null
vendor/statamic/cms/src/Stache/Query/Builder.php:49

This results in a 500 on both the CP and the frontend.

Since paths and indexes are cached under separate keys and invalidated independently, a query using a where or orderBy resolves its keys from a field index, so the index hands back a key of a file that no longer exists.

Filtering out the nulls in Builder::getItems() resolves the issue. Refreshing the Stache remains the fix for the stale index itself but this stops throwing a 500 error.

Thank to Ivan for reporting this through support.

@jasonvarga
jasonvarga merged commit 3cb09f0 into 6.x Jul 22, 2026
23 checks passed
@jasonvarga
jasonvarga deleted the fix-stache-orphaned-index-keys branch July 22, 2026 20:15
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