Skip to content

πŸ› Admin API always saves revisions even when save_revision=falseΒ #26677

@markstos

Description

@markstos

Issue Summary

There's a sort order bug in Ghost's revision logic. Here's the chain:

  1. post-revision.js:32-33 β€” orderDefaultRaw() returns 'created_at_ts DESC' β€” newest first
  2. post.js:920-926 β€” revisions are fetched via findAll β†’ gets them in DESC order (newest first)
  3. 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

  1. Make an Admin API call to create a post.
  2. Check revisions.
  3. Make an Admin API call to update a post with save_revision=false in the query string.
  4. Check revision count.
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs:triage[triage] this needs to be triaged by the Ghost team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions