From abe62d22d484dd67c67247cc41993c189ebdf786 Mon Sep 17 00:00:00 2001 From: "Marco (Valandur)" Date: Wed, 10 Oct 2018 14:14:03 +0200 Subject: [PATCH] fix(publish): Fix publish being detected as new change --- src/PageElement.php | 7 ++++++- src/PageSection.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/PageElement.php b/src/PageElement.php index 4c636e5..eb9386d 100755 --- a/src/PageElement.php +++ b/src/PageElement.php @@ -142,11 +142,16 @@ public function onAfterWrite() { parent::onAfterWrite(); - if (Versioned::get_stage() == Versioned::DRAFT) { + if (Versioned::get_stage() == Versioned::DRAFT && $this->isChanged("__Counter", DataObject::CHANGE_VALUE)) { foreach ($this->PageSections() as $section) { $section->__Counter++; $section->write(); } + + foreach ($this->Parents() as $parent) { + $parent->__Counter++; + $parent->write(); + } } } diff --git a/src/PageSection.php b/src/PageSection.php index 25dd1de..68da74f 100644 --- a/src/PageSection.php +++ b/src/PageSection.php @@ -62,7 +62,7 @@ public function onAfterWrite() { parent::onAfterWrite(); - if (!$this->__isNew && Versioned::get_stage() == Versioned::DRAFT) { + if (!$this->__isNew && Versioned::get_stage() == Versioned::DRAFT && $this->isChanged("__Counter", DataObject::CHANGE_VALUE)) { $this->Parent()->__PageSectionCounter++; $this->Parent()->write(); }