Skip to content

Commit

Permalink
fix(publish): Fix publish being detected as new change
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco (Valandur) committed Oct 10, 2018
1 parent c269a7b commit abe62d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/PageElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/PageSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit abe62d2

Please sign in to comment.