Skip to content

[6.x] Give release statuses an explicit transition table - #20793

Open
riasvdv wants to merge 3 commits into
6.xfrom
rias/release-status
Open

riasvdv wants to merge 3 commits into
6.xfrom
rias/release-status

Conversation

@riasvdv

@riasvdv riasvdv commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Description

Release status checks were repeated in five places, and nothing could move a release out of Publishing. ReleaseStatus::canTransitionTo() is now the single table, and every status write goes through Release::transitionTo() as a compare-and-set.

Draft      -> Scheduled, Publishing, Failed
Scheduled  -> Draft, Publishing, Failed
Failed     -> Scheduled, Publishing, Failed
Publishing -> Published, Failed
Published  -> (none)
  • ReleasePolicy, ReleasesController and ReleaseViewModel use the table instead of their own status lists.
  • A release left in Publishing after its publication throws, such as when MySQL commits the transaction implicitly, moves to Failed, and managers are notified.
  • The MCP releases_get description says a future publishedAt is the scheduled time.

Evidence

  • Before: a publication that threw after an implicit commit left the release in Publishing, which every action rejects.
    After: Releases::publishRelease() moves it to Failed. ReleasesTest covers the transition table and the guards that now use it.

riasvdv and others added 3 commits November 17, 2026 15:07
ReleaseStatus::canTransitionTo() now defines which status changes are
allowed, and every status write in Releases goes through
Release::transitionTo(). It updates the row only if its status is still the
one it was read with. The unschedule and publish guards, the publish and
schedule policy checks, the publish modal and the "can unschedule" flag all
read the same table instead of their own status lists.

unscheduleIfEmpty() now reloads the release first. Applying a scheduled
release's last draft early already unschedules it through
withElementDeletion(), and the second write came from an outdated copy.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1e8d1-9981-7090-9108-69125aec9ad4
Co-authored-by: Amp <amp@ampcode.com>
A release only enters Publishing inside the publication transaction, so a
failure normally rolls it back. When something commits that transaction
early, such as a MySQL statement with an implicit commit, the release stayed
Publishing, and nothing can publish, schedule or delete a release in that
status.

publishRelease() now moves a release that's still Publishing after its
publication threw to Failed, and notifies release managers.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1e8d1-9981-7090-9108-69125aec9ad4
Until a release publishes, publishedAt holds the time it's scheduled for.
The releases_get description now says so, so agents don't read a future
date as the time it was published.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1e8d1-9981-7090-9108-69125aec9ad4
@github-actions

Copy link
Copy Markdown

📚 Storybook previews

@craftcms/ui — open Storybook

No changed components detected in this Storybook.

resources/js — open Storybook

No changed components detected in this Storybook.

This branch has not been deployed

No deployments
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.

1 participant