-
-
Notifications
You must be signed in to change notification settings - Fork 546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.x] Avoid querying status #9317
Merged
Merged
Conversation
This file contains 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
2 tasks
jasonvarga
force-pushed
the
avoid-status
branch
from
January 17, 2024 19:34
7bb02e7
to
0add0e2
Compare
# Conflicts: # src/Query/StatusQueryBuilder.php # src/Stache/Query/EntryQueryBuilder.php # tests/Data/Entries/EntryQueryBuilderTest.php
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.
Closes #2217
The issue
When you have a collection with date behaviors like a typical blog with scheduled posts (past dates are visible, future dates are not) whenever the current time ticks over the scheduled date, the entry would not be displayed.
This is because we were filtering by "status" in order to prevent drafts from being displayed by default.
The future dated entries have a status of "scheduled", and they get stored in the Stache index (or even in the database table if using the Eloquent driver). When the time ticks over the publish date, there's nothing that would update the indexed status, so the entry would continue to be filtered out.
The solution
This PR reworks logic so that we don't ever query status, as it would never automatically update. We would only query by date logic plus whether the entries are published.
Thinking of it more like a traditional database, you're currently querying
status
as if it were a column.With this PR, consider the column gone, and to query by "status" it would really be a more complex query scope.
Breaking changes
In this PR, there should be none. However there will be some for v6 in a separate PR.
At the moment, you can still use all the condition types in your tag or API requests, e.g.
status:in="draft|published"
orstatus:not="whatever"
. It'll query against the stored value like it always did, but you may continue to run into the scheduling bug.In v6, those will cause exceptions. Similar to if you were to query a missing column in a database you'd get
Column [status] not found
. In v6 you'll need to usewhereStatus
.In v6, you'll only be able to query single statuses. I believe you only ever used the more complex operators to get around issues. I could be wrong! If that's the case and people really need them, we can add them back by making
whereStatus
smarter, or addingwhereStatusIn
, etc.Todo
For this PR, it logs a deprecation message. In v6, it'll throw an exception.
It's backwards compatible for now because the existing (sometimes broken) behavior will remain unchanged.
By the way
This doesn't address the issue where a listing should get updated while using static caching.
That's solvable using https://statamic.com/addons/mity-digital/scheduled-cache-invalidator