-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Open
Labels
needs:triage[triage] this needs to be triaged by the Ghost team[triage] this needs to be triaged by the Ghost team
Description
Issue Summary
There's a sort order bug in Ghost's revision logic. Here's the chain:
- post-revision.js:32-33 β orderDefaultRaw() returns 'created_at_ts DESC' β newest first
- post.js:920-926 β revisions are fetched via findAll β gets them in DESC order (newest first)
- post-revisions.ts:56 β const latestRevision = revisions[revisions.length - 1] β grabs the last element
So latestRevision is actually the oldest revision, not the newest. The time check on line 84 compares Date.now() against the oldest revision's timestamp β which is almost always >10 minutes old. This means the background_save condition passes every time content has changed, regardless of how recently the last revision was created.
This bug is masked in the Ghost Admin UI because it always sends save_revision=true and there was no test coverage in the test suite for the condition.
The flag is not documented in the Admin API docs, helping the issue to go undetected.
Steps to Reproduce
- Make an Admin API call to create a post.
- Check revisions.
- Make an Admin API call to update a post with save_revision=false in the query string.
- Check revision count.
- Make an Admin API call to update a post with save_revision=false in the query string.
Revision count should not be increasing, but it is.
Ghost Version
6.20.0
Node.js Version
22.22.0
How did you install Ghost?
Podman, systemd, Fedora Linux
Database type
MySQL 8
Browser & OS version
N/A
Relevant log / error output
N/A.Code of Conduct
- I agree to be friendly and polite to people in this repository
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
needs:triage[triage] this needs to be triaged by the Ghost team[triage] this needs to be triaged by the Ghost team