diff --git a/src/base/Element.php b/src/base/Element.php index 92e4cd80..680b0c04 100644 --- a/src/base/Element.php +++ b/src/base/Element.php @@ -201,8 +201,10 @@ public function disable($elementIds) foreach ($elementIds as $elementId) { /** @var BaseElement $element */ $element = $elementsService->getElementById($elementId, $class); - $element->enabled = false; - $elementsService->saveElement($element, true, true, Hash::get($this->feed, 'updateSearchIndexes')); + if ($element->enabled) { + $element->enabled = false; + $elementsService->saveElement($element, true, true, Hash::get($this->feed, 'updateSearchIndexes')); + } } return true; @@ -226,8 +228,10 @@ public function disableForSite($elementIds) foreach ($query->each() as $element) { /** @var BaseElement $element */ - $element->enabledForSite = false; - $elementsService->saveElement($element, false, false, Hash::get($this->feed, 'updateSearchIndexes')); + if ($element->enabledForSite) { + $element->enabledForSite = false; + $elementsService->saveElement($element, false, false, Hash::get($this->feed, 'updateSearchIndexes')); + } } return true;