Skip to content

[6.x] Only count published entries in augmented entries fields - #15546

Merged
jasonvarga merged 1 commit into
6.xfrom
status-query-builder-counts
Sep 30, 2026
Merged

jasonvarga merged 1 commit into
6.xfrom
status-query-builder-counts

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request fixes an issue where calling count(), exists(), pluck() and other result methods on an augmented entries field (or a term's entries) would include unpublished entries, even though get() only returns published ones.

This meant {{ related | count }} could disagree with {{ related }}...{{ /related }}, and {{ if related | count }} would pass when every selected entry was a draft.

This was happening because StatusQueryBuilder only applied its fallback status in get(). Every other method was forwarded straight to the underlying query builder via __call.

This PR fixes it by applying the fallback status before any of the builder's result methods are forwarded (count, exists, pluck, paginate, etc). Explicitly querying a status, or calling whereAnyStatus(), still turns the fallback off.

Fixes #15536

@jasonvarga
jasonvarga merged commit bbbc73a into 6.x Sep 30, 2026
65 checks passed
@jasonvarga
jasonvarga deleted the status-query-builder-counts branch September 30, 2026 14:56
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.

StatusQueryBuilder only applies its status filter in get(), so count() and exists() include unpublished entries

2 participants