Skip to content

[6.x] Revision Query builder#10437

Merged
jasonvarga merged 23 commits into
statamic:masterfrom
ryanmitchell:feature/revisions-query-builder
Nov 4, 2025
Merged

[6.x] Revision Query builder#10437
jasonvarga merged 23 commits into
statamic:masterfrom
ryanmitchell:feature/revisions-query-builder

Conversation

@ryanmitchell

Copy link
Copy Markdown
Contributor

This PR changes revisions to work from a stache store and adds a query builder to allow revisions to be queried using the supported methods.

I've tried to implement this in a non breaking way so some of the choices are based around that.

@edalzell wanted this for some filters he's working on.

@jasonvarga jasonvarga changed the base branch from 5.x to master October 30, 2025 18:57
@jasonvarga jasonvarga changed the title [5.x] Revision Query builder [6.x] Revision Query builder Oct 30, 2025
A working copy is now just a revision with an action of "working".

This more inline with a database. It would be in the same table. Eloquent driver already works this way.
the id is the key and the timestamp. at least for the file implementation.

since you can now do Revision::query()->get(), you'd get revisions across entries, terms, etc. So the timestamp alone isn't unique enough.

the filename is essentially irrelevant now.

for eloquent, the id could just be the model row id.

the url continues uses the timestamp, but now its by calling timestamp explicitly, not just assuming id is the timestamp.
to avoid decisions around what querying entry data is, throw an exception for now. only support querying certain fields.
@jasonvarga

Copy link
Copy Markdown
Member

Retargeted this to master so it can be in v6 and have (fairly minor) breaking changes. Went ahead and updated some other parts aside from the query builder too.

  • The path is defined in stache.php with all the other stache paths. But the default value will look at the existing statamic.revisions.path config so things will continue to work.
  • The WorkingCopy class has been removed. A working copy is just a Revision with an action of working. You can use $revision->isWorkingCopy() instead of $revision instanceof WorkingCopy.
  • Revision id is not settable. It's either {$key}/{$timestamp} or {$key}/working. For the eloquent driver, the id would just be the model's id.
  • When messages, users, etc are missing, they are null instead of false.

@jasonvarga jasonvarga merged commit 6a101c6 into statamic:master Nov 4, 2025
18 checks passed
@ryanmitchell ryanmitchell deleted the feature/revisions-query-builder branch November 5, 2025 07:02
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.

2 participants