Store entry statuses statically#17024
Merged
brandonkelly merged 3 commits into5.7from Apr 4, 2025
Merged
Conversation
[ci skip]
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
Adds a new
statuscolumn to theentriestable, which statically stores entries’ last-known date-based status (live,pending, orexpired), updated whenever entries are saved.By default the column is completely ignored by element queries, and entry queries will continue taking the
postDateandexpiryDatecolumns into account when fetching entries bylive/pending/expiredstatus.However, that behavior can be altered using a new
staticStatusesconfig setting. When that’s enabled, entry queries will look at thestatuscolumn instead ofpostDateandexpiryDate. So if an entry is saved with a future post date, and itsstatuscolumn is set topending, it will continue to be excluded from entry query results forliveentries, even passed its post date, until it’s saved again.There’s also a new
update-statusescommand, which will look for entries whose statically-stored statuses need to be updated based on theirpostDateandexpiryDatevalues, and resaves them so their statuses get updated (and caches get cleared, etc.).Sites with
staticStatusesenabled should start runningupdate-statusesevery 1 or 5 minutes using a Cron job, to ensure that statically-stored entry statuses are kept up-to-date.And finally, entries have a new
oldStatusproperty, making it easy for event listeners to catch the moment that an entry goes live or expires:Related issues