You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix!: align global version restoration with collections - #18928
Aligns global version restoration with collections by calling saveVersion within the global restore operation:
Returns the restored global document directly, matching collection restoration (breaking change).
Localized _status values are not normalized when restoring a draft.
versions.max is not enforced, allowing version history to exceed the configured limit.
Draft restores also leave live global content intact.
Breaking Changes
Global restores now return the global document directly. This affects payload.restoreGlobalVersion, REST responses, and global afterRead / afterChange hooks that use the version-row wrapper.
const restored = await payload.restoreGlobalVersion({ slug: 'settings', id: versionID })
-const title = restored.version.title+const title = restored.title
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Global version restoration now persists restored data through saveVersion and updates existing globals only for non-draft restores. The SDK restore methods return the global document directly. Tests cover draft handling, localized data, version limits, and the updated response shape.
Changes: Global Version Restore
Layer / File(s)
Summary
Restore and persist global versions packages/payload/src/globals/operations/restoreVersion.ts, test/versions/int.spec.ts
The restore operation accepts JsonObject, skips global updates for draft restores, and saves restored data through saveVersion. Tests cover localized restores, draft behavior, live data, and version limits.
Direct global response contract packages/sdk/src/globals/restoreVersion.ts, packages/sdk/src/index.ts, test/access-control/int.spec.ts, test/sdk/int.spec.ts, test/versions/int.spec.ts
SDK restore methods return the restored global document directly. Updated assertions read restored fields from the document root, including the GraphQL response test.
sequenceDiagram
participant restoreVersionOperation
participant updateGlobal
participant saveVersion
opt Existing global and not restoring as draft
restoreVersionOperation->>updateGlobal: update restored global
end
restoreVersionOperation->>saveVersion: persist restored data and draft state
saveVersion-->>restoreVersionOperation: return saved version data
Architecture concerns
No architecture-level concerns identified.
Review details
Systems and components
observed — test (service) was modified; 3 changed files map to changed impact.
observed — packages/sdk (library) was modified; 2 changed files map to changed impact.
observed — packages/payload (library) was modified; 1 changed file maps to changed impact.
Before / after behavior
observed — Modified behavior in packages/payload/src/globals/operations/restoreVersion.ts: The operation now imports JsonObject and no longer imports TypeWithVersion.
observed — Modified behavior in packages/payload/src/globals/operations/restoreVersion.ts: Adds the saveVersion dependency used to persist restored versions.
observed — Modified behavior in packages/payload/src/globals/operations/restoreVersion.ts: restoreVersionOperation changes its generic constraint from TypeWithVersion<T> to JsonObject.
observed — Modified behavior in packages/payload/src/globals/operations/restoreVersion.ts: The update path now runs when a global exists or a draft restore is requested, but skips updateGlobal for drafts. The previous inline update-and-createGlobalVersion sequence is removed from this block.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 6 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description check
The description clearly explains the global version restoration changes, the breaking API change, and the affected behavior.
Title check
The title is concise and accurately identifies the main change: aligning global version restoration with collection restoration.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Git: CodeRabbit could not clone the repository, so clone-backed analysis was skipped and this review may be incomplete. Verify repository clone access, such as SSH credentials, before requesting another full review. If clone access is intentionally unavailable, use path_filters to narrow the review scope.
Comment @coderabbitai help to get the list of available commands.
jacobsfletch
changed the title
fix!: normalize restored global statuses and enforce version limits
fix!: align global version restoration with collections
Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continuation of #13333.
Aligns global version restoration with collections by calling
saveVersionwithin the global restore operation:_statusvalues are not normalized when restoring a draft.versions.maxis not enforced, allowing version history to exceed the configured limit.Draft restores also leave live global content intact.
Breaking Changes
Global restores now return the global document directly. This affects
payload.restoreGlobalVersion, REST responses, and globalafterRead/afterChangehooks that use the version-row wrapper.const restored = await payload.restoreGlobalVersion({ slug: 'settings', id: versionID }) -const title = restored.version.title +const title = restored.title