Skip to content

Drafts, Revisions & Scheduling

Entries keeps unpublished working drafts, point-in-time revision snapshots, and trashed items isolated in entries_history so editors can iterate safely without touching live data.

Working drafts (primary, named, and per-user)

Section titled “Working drafts (primary, named, and per-user)”

Every Single and Collection editor includes Save Draft, Auto save, and Named Draft controls in the top bar (enabled by default; set drafts: false on a blueprint to disable).

  • Multiple editors can keep independent named or per-user drafts on the same live entry.
  • Live queries ($entries->find()) never expose draft edits unless you explicitly pass include=drafts (or drafts=1).
<?php
declare(strict_types=1);
namespace ProcessWire;
$entries = wire()->entries;
$season = $entries->findOne('type=seasons, code=HIGH_2026');
if ($season !== null) {
$season->set('rate_multiplier', 1.65);
// Stage a primary, named, or per-user draft
$season->saveDraft();
$season->saveDraft(['key' => 'summer-promo', 'name' => 'Summer Promo', 'perUser' => true]);
if ($season->hasDraft('summer-promo')) {
$allDrafts = $season->drafts();
$draftCount = $entries->countDrafts($season);
$draftItem = $season->getDraft('summer-promo');
$changes = $season->diffDraft('summer-promo');
// Publish the draft to live (optionally discarding sibling drafts)
$season->publishDraft('summer-promo', discardOtherDrafts: true);
// Or discard: $season->discardDraft('summer-promo'); / $season->discardAllDrafts();
}
}
// Query entries with active working drafts overlaid in a single batch query
$previewList = $entries->find('type=seasons, include=drafts');

Share a live preview link of an unpublished draft with external reviewers without giving them admin accounts. Tokens are HMAC-SHA256 signed, clamped between 60 and 604800 seconds, and automatically redact sensitive fields:

<?php
declare(strict_types=1);
namespace ProcessWire;
$entries = wire()->entries;
$route = $entries->findOne('type=routes, name=gocek-12-islands');
if ($route !== null) {
// Requires edit permission to mint
$token = $entries->createPreviewToken($route, draft: 'summer-promo', ttlSeconds: 3600);
// Resolve safely in a frontend template
$previewItem = $entries->resolvePreviewToken($token, allowLiveFallback: true);
}

Revision history, diffs, and selective restore

Section titled “Revision history, diffs, and selective restore”

Enable revision tracking on any blueprint with revisions: true or a retention cap such as revisions: 10:

site/entries/collections/seasons.yaml
revisions: 10

In the admin editor, open the Revisions tab to inspect rich field-by-field diffs and restore full snapshots or selected fields. Entries verifies physical media integrity before restoring snapshots that reference uploaded images or files.

<?php
declare(strict_types=1);
namespace ProcessWire;
$entries = wire()->entries;
$season = $entries->findOne('type=seasons, code=HIGH_2026');
if ($season !== null) {
// Attach an editorial note before saving
$season->setRevisionNote('Updated 2027 peak charter multiplier');
$entries->save($season);
$snapshots = $season->revisions(limit: 10);
foreach ($snapshots as $rev) {
$note = $rev->getRevisionNote();
$changed = implode(', ', $rev->getChangedFields());
echo "Revision {$rev->id} ({$note}) changed [{$changed}]\n";
}
if ($snapshots !== []) {
// Inspect field-by-field diff
$diff = $season->diffRevision($snapshots[0]->id);
// Restore only specific fields without overwriting the rest of the entry
$season->restoreRevisionFields($snapshots[0]->id, ['rate_multiplier', 'end_date']);
// Or restore the entire entry and its nested blocks
$season->restoreRevision($snapshots[0]->id);
}
}

Trashing a record sets STATUS_TRASH (and cascades to two-level child entries) instead of deleting it immediately:

<?php
declare(strict_types=1);
namespace ProcessWire;
$entries = wire()->entries;
$entries->trash($season);
$entries->restore($season);
// Permanently purge trashed items older than 30 days
$purgedCount = $entries->emptyTrash('seasons', olderThanDays: 30);

Add publishable: true to a collection blueprint to enable publish_from and publish_until scheduling fields:

site/entries/collections/promotions.yaml
title: Seasonal Promotions
kind: collection
publishable: true
  1. Set a future Publish From date (and optional Publish Until expiration date) on your entry and save it.

  2. Add a cron job running entries:schedule (or ProcessWire’s console scheduler) so scheduled transitions run automatically:

    Terminal window
    php vendor/bin/wire entries:schedule --json
  3. Query active, upcoming, or expired items with symbolic status selectors:

    $live = wire()->entries->find('type=promotions, status=live, sort=sort, limit=10');
    $upcoming = wire()->entries->find('type=promotions, status=scheduled, limit=10');
    $expired = wire()->entries->find('type=promotions, status=expired, limit=10');

You can also trigger due transitions directly in PHP via $stats = wire()->entries->processScheduledPublications('promotions'); (returns ['published' => int, 'expired' => int]).

Next steps