Does restoring a Sulu page version preserve properties removed from the current template?
0 reputation · 26 May 2021, 16:03 UTC
0 reputation · 26 May 2021, 16:03 UTC
Sulu's Administration UI offers a documented versions list that lets editors restore a previous page version, but the behavior is uncertain when the page template's property schema changed after that version was saved. In Sulu 2.x, templates are defined in XML and content is persisted through Doctrine, so a restored version may contain properties the current template no longer defines, or lack properties the template now requires.
The unresolved decision is whether the restore operation drops properties absent from the current template, retains them as orphaned data, or blocks the restore entirely. This editor-facing rollback is separate from Doctrine migration downgrades, which Sulu upgrade guidance does not document as a supported path. The merge-or-drop semantics are version-sensitive and should be confirmed against the installed PageBundle restore logic.
Which behavior does Sulu apply when restoring a version saved under an older template: property removal, orphan retention, or a validation block? Does the outcome differ between draft and published versions? Where in the installed PageBundle version service should this be verified for a Sulu 2.x project?
35275 reputation · 27 May 2021, 02:48 UTC
In Sulu 2.x, restoring a page version retains the data in the database (as orphaned data) but does not render it in the Administration UI if the property has been removed from the current template XML. The restore operation does not block the process, nor does it automatically purge properties that are no longer defined in the template.
Sulu versions store snapshots of page content. When a restore is triggered, the system loads the versioned data and applies it to the page entity. However, the Sulu Administration UI is dynamically generated based on the current template XML definition. Because the UI only renders fields defined in the active template, any restored properties that are absent from that XML become "invisible" to the editor, even if the values persist in the underlying Doctrine entity or database columns.
The outcome depends heavily on how the property was "removed":
The restore operation typically targets the working copy (draft) of the page. The restored state—including any orphaned data—remains in the draft state until the editor explicitly publishes the page. This allows for a manual review of the page content before the restored (and potentially outdated) structure goes live.
To confirm the exact mapping logic in your specific installation, investigate the following areas of the PageBundle:
Sulu\Bundle\PageBundle\Version\VersionService. Trace the restore method to see how version data is mapped back onto the Page entity.PageManager or PageRepository update methods to determine if there is a filtering mechanism that explicitly drops properties not present in the current template during the save process.Diagnostic Requirement: To provide a more definitive answer on whether data is purged during the save cycle, please specify if your project uses custom Page entities or standard Sulu PageBundle entities.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.