Skip to content

[Bug] Publish a version in place instead of creating a new version - #2162

Open
ValeriaMaltseva wants to merge 4 commits into
2026.3from
fix/publish-version-in-place-1628
Open

ValeriaMaltseva wants to merge 4 commits into
2026.3from
fix/publish-version-in-place-1628

Conversation

@ValeriaMaltseva

Copy link
Copy Markdown
Contributor

Changes in this pull request

Resolves pimcore/service-operations#1628 (Jira PEES-1896, "Problem 2")

"Publish" on a version restored the version data into the element and saved it, which always created a new versions row: the published version stayed an unpublished entry, a copy of its content became the live version, and the endpoint returned whatever version happened to be the newest one.

  • The three version publishers get the version they publish and write the published state into it (save(['existingVersion' => $version]), see [Bug] Publish a version in place instead of creating a new version pimcore#19620), so the history shows that exactly this version went live.
  • VersionService::publishVersion() returns the id of the published version instead of looking up the "last version" (which, after an in-place publish, could be a newer, unrelated row).
  • pimcore/pimcore is required at ^2026.3.4, the release that ships the save parameter.

Companion PR (core, scheduled publish-version task + the save parameter): pimcore/pimcore#19620

Additional info

Reproduce: open a data object, "Save draft", then in the Versions tab click "Publish" on that draft version. Before: a new published version appears and the draft stays an unpublished entry. After: the draft version itself is marked as published, no version is added.

Tests: unit tests for the three publishers and VersionService::publishVersion() (tests/Unit/Version/Publisher, tests/Unit/Version/Service), run locally: 9 tests green. PHPStan is clean for the changed files; the remaining errors in src/Version locally are the pre-existing coauthor accessors missing from the container's older core package.

🤖 Generated with Claude Code

ValeriaMaltseva and others added 2 commits October 27, 2026 17:51
Publishing a version restored the version data into the element and
saved it, which always created a new versions row: the published
version stayed an unpublished entry and the endpoint returned whatever
version happened to be the newest one. The publishers now write the
published state into the version itself (core `existingVersion` save
parameter) and the endpoint returns the id of that version.

Refs pimcore/service-operations#1628

Co-Authored-By: Claude <noreply@anthropic.com>
The `existingVersion` save parameter the publishers rely on ships with
pimcore/pimcore 2026.3.4 (pimcore/pimcore#19620).

Co-Authored-By: Claude <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The necessary core dependency bump conflicts with the repository’s manifest restriction and needs explicit maintainer resolution before merging.

1 open issue
What changed in this PR

This PR fixes version publishing in Studio by updating the selected version in place rather than creating a duplicate history entry.

Changes:

  • Pass the selected Version through all three publisher interfaces to save(['existingVersion' => $version]).
  • Return that version’s ID instead of querying the newest version.
  • Add publisher and service regression tests and raise the minimum core dependency.

The fix targets the underlying save behavior at the publisher/service boundary (DataObjectVersionPublisher.php:40, VersionService.php:133–139). All three publisher contracts are updated and remain @internal. Tests cover argument forwarding and the returned ID, but were not run during this review; actual persistence depends on the still-open companion core PR pimcore/pimcore#19620. Interface documentation is updated; no bundle changelog is included.

File Description
tests/​Unit/​Version/​Service/​VersionServiceTest.php Tests selected-version forwarding, returned ID, and unsupported publishers.
tests/​Unit/​Version/​Publisher/​DocumentVersionPublisherTest.php Tests document publishing and missing-document handling.
tests/​Unit/​Version/​Publisher/​DataObjectVersionPublisherTest.php Tests object publishing, folder exclusion, and save failures.
tests/​Unit/​Version/​Publisher/​AssetVersionPublisherTest.php Tests asset publishing and save failures.
src/​Version/​Service/​VersionService.php Passes the selected version and returns its ID.
src/​Version/​Publisher/​DocumentVersionPublisherInterface.php Adds the selected version to the document publisher contract.
src/​Version/​Publisher/​DocumentVersionPublisher.php Saves into the selected document version.
src/​Version/​Publisher/​DataObjectVersionPublisherInterface.php Adds the selected version to the object publisher contract.
src/​Version/​Publisher/​DataObjectVersionPublisher.php Saves into the selected object version.
src/​Version/​Publisher/​AssetVersionPublisherInterface.php Adds the selected version to the asset publisher contract.
src/​Version/​Publisher/​AssetVersionPublisher.php Saves into the selected asset version.
composer.json Raises the core requirement to ^2026.3.4.

Review effort: Balanced

Comment thread composer.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Publishing can overwrite another user's autosave or report a draft as published without updating it, and version history may display newly published drafts out of order.

3 open issues
1 resolved since last review

Review effort: Balanced

Comment thread src/Version/Service/VersionService.php Outdated
Comment thread src/Version/Service/VersionService.php Outdated
Comment thread src/Version/Service/VersionService.php
The version is published in place, so publishing another user's auto-save
version would take it over (owner and content), as deleting it is not allowed
either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Note

This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Two critical issues remain: a failed publish can overwrite the original draft despite a database rollback, and concurrent autosaves can overwrite newer edits or revert a published version to an autosave.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread src/Version/Publisher/DataObjectVersionPublisher.php Outdated
Comment thread src/Version/Service/VersionService.php
Auto-save versions are rewritten by the editor of their user at any time,
writing into one would race with that (pimcore/pimcore#19620 rejects it). They
are published as a new version, as before, which also makes rejecting the
auto-save version of another user unnecessary: nothing is taken over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/Version/Service/VersionService.php
Comment thread src/Version/Service/VersionService.php

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

In-place publishing can orphan old snapshots when rewritten data crosses the storage-size threshold, leaving them outside normal version deletion.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment thread src/Version/Service/VersionService.php
@ValeriaMaltseva
ValeriaMaltseva requested a review from mcop1 October 28, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants