Skip to content

Use try-finally for disable/enable versioning#97

Merged
solverat merged 10 commits intoopen-dxp:1.xfrom
blankse:patch-1
Feb 25, 2026
Merged

Use try-finally for disable/enable versioning#97
solverat merged 10 commits intoopen-dxp:1.xfrom
blankse:patch-1

Conversation

@blankse
Copy link
Contributor

@blankse blankse commented Feb 25, 2026

Followup to #95

@github-actions
Copy link

Review Checklist

  • Target branch (1.0 for bug fixes, others 1.x)
  • Tests (if it's testable code, there should be a test for it - get help)
  • Docs (every functionality needs to be documented, see here)
  • Migration incl. install.sql (e.g. if the database schema changes, ...)
  • Upgrade notes (deprecations, important information, migration hints, ...)
  • Label
  • Milestone

@blankse
Copy link
Contributor Author

blankse commented Feb 25, 2026

@solverat Here is the PR :)

@blankse blankse changed the title Refactor saveWithoutVersion to use try-finally for versioning. Use try-finally for disable/enable versioning Feb 25, 2026
@solverat
Copy link
Contributor

@blankse Thanks for the quick response! I'll merge it for now. We may should consider outsourcing this method to a Helper and use it here too:

Model\Version::disable();
$this->save(); // auto save
Model\Version::enable();

Model\Version::disable();
$this->save(); // auto save
Model\Version::enable();

Model\Version::disable();
$className = $element::class;
/** @var Document|Asset|AbstractObject $dummy */
$dummy = OpenDxp::getContainer()->get('opendxp.model.factory')->build($className);
$dummy->setId($element->getId());
$dummy->setParentId($element->getParentId() ?: 1);
$dummy->setKey($element->getKey());
if ($dummy instanceof DataObject\Concrete) {
$dummy->setOmitMandatoryCheck(true);
}
$dummy->save(['isRecycleBinRestore' => true]);
Model\Version::enable();

Version::disable();
$asset->markFieldDirty('modificationDate'); // prevent modificationDate from being changed
$asset->save($saveParams);
Version::enable();

@solverat solverat self-assigned this Feb 25, 2026
@solverat solverat added the enhancement New feature or request label Feb 25, 2026
@solverat solverat added this to the 1.2.3 milestone Feb 25, 2026
Co-authored-by: Jacob Dreesen <jacob@hdreesen.de>
blankse and others added 2 commits February 25, 2026 10:49
Co-authored-by: Jacob Dreesen <jacob@hdreesen.de>
Co-authored-by: Jacob Dreesen <jacob@hdreesen.de>
@solverat solverat self-requested a review February 25, 2026 12:11
@solverat solverat merged commit 39da8f8 into open-dxp:1.x Feb 25, 2026
12 checks passed
@solverat
Copy link
Contributor

@blankse Very nice! Thank you for your efforts! Thanks @jdreesen for reviewing!

@github-actions github-actions bot locked and limited conversation to collaborators Feb 25, 2026
@blankse blankse deleted the patch-1 branch February 25, 2026 12:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants