Repository navigation
fix(core): exclude unpublished entries from taxonomy term counts - #1839
Closed
ColoradoClimbr wants to merge 1 commit into
Closed
ColoradoClimbr wants to merge 1 commit into
ColoradoClimbr wants to merge 1 commit into
Conversation
getTaxonomyTermCounts() aggregated content_taxonomies with no status filter, so a draft post attached to a term inflated that term's count in widgets like the "Categories" sidebar even though the draft never renders publicly. content_taxonomies has no FK to the per-collection ec_* tables that hold status, so the fix joins against each distinct collection present in the pivot and applies the same published-or-scheduled-and-due condition loader.ts already uses for content queries (buildStatusCondition, now exported for reuse here). Fixes #581
🦋 Changeset detectedLatest commit: 8c4c6a9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
9 of 18 tasks
Member
|
Thanks for your work on this. There are currently several overlapping PRs that each manage part of this, but none of them manage the lot. I've found the simplest solution is to create a new PR inspired by all of them. For that reason I'm going to close this in favour of #1892 |
ascorbic
added a commit
that referenced
this pull request
Jul 9, 2026
…1892) * fix(taxonomies): count only publicly visible entries in term counts (#581) Term usage counts aggregated the content_taxonomies pivot directly, so drafts, scheduled-future, and trashed entries inflated the counts shown in the Categories/Tags widgets, on term pages, and in the admin term list. All three paths now share a single UNION ALL count query that joins the content tables, filters with buildStatusCondition (published or scheduled-and-due) and deleted_at IS NULL, and scopes to the taxonomy's declared collections. Consolidates the fixes proposed in #1839, #822, and #593. * ci: update query-count snapshots * fix(taxonomies): include collection scope in term-count request-cache key Per-locale rows of the same taxonomy def can drift in their declared collections, and a future caller may pass a narrower scope; keying the request cache by taxonomy name alone let the first scope poison the entry for the rest of the request. Raised by review on #1892. --------- Co-authored-by: emdashbot[bot] <emdashbot[bot]@users.noreply.github.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.
What does this PR do?
getTaxonomyTermCounts()aggregatedcontent_taxonomieswith no status filter, so a draft post attached to a term inflated that term's count in widgets like the "Categories" sidebar even though the draft never renders publicly.content_taxonomieshas no FK to the per-collectionec_*tables that hold status, so the fix joins against each distinct collection present in the pivot and applies the same published-or-scheduled-and-due conditionloader.tsalready uses for content queries (buildStatusCondition, now exported for reuse here).Closes #581
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure
Screenshots / test output
packages/core/tests/unit/taxonomies/get-taxonomy-terms.test.ts— 3/3 pass;pnpm lint:quickclean;pnpm typecheckclean. (Full-suite run also shows 4 pre-existing failures intests/unit/cli/bundle-utils.test.tsunrelated to this change — Windows/Git-Bashtarpath mangling in the local dev environment, reproduces identically onmain.)Opened as draft: fork already has several open PRs against this repo (non-collaborator open-PR limit).