Skip to content

[5.x] Only apply the published filter when not in preview mode#11652

Merged
jasonvarga merged 8 commits intostatamic:5.xfrom
TheBnl:fix/published-filter-preview-gql
Apr 25, 2025
Merged

[5.x] Only apply the published filter when not in preview mode#11652
jasonvarga merged 8 commits intostatamic:5.xfrom
TheBnl:fix/published-filter-preview-gql

Conversation

@TheBnl
Copy link
Copy Markdown
Contributor

@TheBnl TheBnl commented Apr 2, 2025

Possible fix for issue #6134

Checks if we're in isLivePreview before appending $filters['status'] = 'published';
Works similar as the fix made for the REST API #10229

Copy link
Copy Markdown
Member

@duncanmcclean duncanmcclean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be able to add a test for this?

@TheBnl
Copy link
Copy Markdown
Contributor Author

TheBnl commented Apr 4, 2025

Sure, i'll setup a test for checking if draft entries are received with a token and omitted without a token. 👍

@TheBnl
Copy link
Copy Markdown
Contributor Author

TheBnl commented Apr 4, 2025

I've added the testcase. While running the test I also needed to fix a line where the filters would default to null when empty. This should actually default to an empty array, further down the line the array type is required. Because published was always filtered this was previously not an issue.

@TheBnl TheBnl requested a review from duncanmcclean April 4, 2025 08:33
@TheBnl
Copy link
Copy Markdown
Contributor Author

TheBnl commented Apr 11, 2025

@duncanmcclean have you had a chance to review the changes? 😃

@duncanmcclean
Copy link
Copy Markdown
Member

Sorry, I don't normally review PRs, beyond giving them a quick look over, so I don't have an ETA for when we'll review this pull request.

In the meantime, you can pull this PR into your project with a composer patch.

@jasonvarga
Copy link
Copy Markdown
Member

I've adjusted this so that it only applies to the single entry query. This is consistent with the rest api.

@jasonvarga jasonvarga merged commit 56f0f31 into statamic:5.x Apr 25, 2025
24 checks passed
@TheBnl
Copy link
Copy Markdown
Contributor Author

TheBnl commented Apr 26, 2025

Thanks for the merge! 🔥

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.

3 participants