From 0226bb90f71a268406c08135c33dd53a72a5a43b Mon Sep 17 00:00:00 2001 From: Michal Kleiner Date: Mon, 13 Apr 2020 21:52:27 +1200 Subject: [PATCH] Adjust onBeforeDelete hook to only act when deleting from draft stage --- src/Models/DataObjectTaxonomyTerm.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Models/DataObjectTaxonomyTerm.php b/src/Models/DataObjectTaxonomyTerm.php index 8257b23..64a63d1 100644 --- a/src/Models/DataObjectTaxonomyTerm.php +++ b/src/Models/DataObjectTaxonomyTerm.php @@ -42,8 +42,10 @@ public function onBeforeDelete() parent::onBeforeDelete(); if ($this->hasExtension(Versioned::class)) { - if ($this->canUnpublish()) { - $this->doUnpublish(); + if (Versioned::get_stage() === Versioned::DRAFT) { + if ($this->canUnpublish()) { + $this->doUnpublish(); + } } } }