Skip to content

[6.x] Respect collection wheres inside nested where closures - #15563

Merged
jasonvarga merged 1 commit into
statamic:6.xfrom
lazerg:fix/issue-15560-nested-collection-where
Oct 5, 2026
Merged

jasonvarga merged 1 commit into
statamic:6.xfrom
lazerg:fix/issue-15560-nested-collection-where

Conversation

@lazerg

@lazerg lazerg commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

This pull request fixes an issue where where('collection', ...) or whereIn('collection', ...) inside a nested where() / orWhere() closure was silently ignored by the Stache entry query builder.

The builder pulls collection clauses out of the wheres and keeps them in its $collections property, so they decide which collection stores get queried. The closure gets a clone of the builder, so the clause landed on the clone's $collections, which is never read. The nested query ended up with no wheres and was dropped, and entries from every collection came back.

This PR fixes it by marking the nested builder, and turning collection clauses on it into a regular where on the collectionHandle index, the same index the status query already uses for its per-collection clauses. That way and / or inside the closure work like any other column.

Fixes #15560

@jasonvarga
jasonvarga merged commit 6b670df into statamic:6.x Oct 5, 2026
62 checks passed
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.

Stache: ->where('collection', …) inside a nested where() closure is silently ignored

2 participants