diff --git a/src/base/Element.php b/src/base/Element.php index d68d16b8944..695affcffa4 100644 --- a/src/base/Element.php +++ b/src/base/Element.php @@ -4949,6 +4949,20 @@ protected function showStatusField(): bool return true; } + /** + * Public method that returns whether status field should be shown for given element. + * It's a temporary solution, to be removed in v5 when Element::showStatusField() can be set to be public. + * (introduced to deal with #13854) + * + * @return bool + * @since 4.5.9 + * @deprecated @4.5.9 + */ + public function getShowStatusField(): bool + { + return $this->showStatusField(); + } + /** * Returns the status field HTML for the sidebar. * diff --git a/src/elements/actions/SetStatus.php b/src/elements/actions/SetStatus.php index 8b7b05dc291..22660b6b22c 100644 --- a/src/elements/actions/SetStatus.php +++ b/src/elements/actions/SetStatus.php @@ -90,6 +90,12 @@ public function performAction(ElementQueryInterface $query): bool foreach ($elements as $element) { switch ($this->status) { case self::ENABLED: + // Skip if we're not supposed to allow changing status + /** @var Element $element */ + if (!$element->getShowStatusField()) { + continue 2; + } + // Skip if there's nothing to change if ($element->enabled && $element->getEnabledForSite()) { continue 2; @@ -101,6 +107,12 @@ public function performAction(ElementQueryInterface $query): bool break; case self::DISABLED: + // Skip if we're not supposed to allow changing status + /** @var Element $element */ + if (!$element->getShowStatusField()) { + continue 2; + } + // Is this a multi-site element? if ($isLocalized && count($element->getSupportedSites()) !== 1) { // Skip if there's nothing to change