Fix draft content leaking to public site#1068
Merged
Conversation
Add _status: 'published' filter to getCachedHomePage and queryEventBySlug queries. These queries were missing the filter that pages and posts already had, allowing draft content to be served to public visitors. Fixes #1067 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Preview deployment: https://fixxdraft-status-filter.preview.avy-fx.org |
rchlfryn
approved these changes
May 9, 2026
Contributor
|
🚀 This is included in version v1.13.1 |
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.
Description
Draft content was being served to public visitors on homePages and individual event pages. The root cause: Payload's
draft: falseparameter onpayload.find()does not automatically add a_status: 'published'filter — it only controls whether to query the versions table vs the main table. Without an explicit_statusfilter, documents with_status: 'draft'are returned to public visitors.The pages and posts queries already had this filter. The homePages and events/[slug] queries did not.
This was surfaced when a deployment cleared the ISR cache, and the fresh queries returned draft content that had been sitting in the database (previously masked by stale cache).
Related Issues
Fixes #1067
Key Changes
getCachedHomePage.ts: Add_status: 'published'filter when not in draft modeevents/[slug]/page.tsx: Add_status: 'published'filter when not in draft mode[slug]/page.tsxandblog/[slug]/page.tsxHow to test
Screenshots / Demo video
https://www.loom.com/share/3ad0ffddf6f942d7903af35b5ac22d1f
FYI
The status column can be pretty confusing, specifically when there is a "previously published" version but not a "currently published version with a newer draft". They both show "Draft (has published version)" even when there is only a previously published version (meaning no published version, really) and not a currently published version. See this comment: payloadcms/payload#10838 (comment)