diff --git a/app/code/Magento/Indexer/Model/Indexer/State.php b/app/code/Magento/Indexer/Model/Indexer/State.php index 25fbcb7d15a53..7fc813f51f199 100644 --- a/app/code/Magento/Indexer/Model/Indexer/State.php +++ b/app/code/Magento/Indexer/Model/Indexer/State.php @@ -1,8 +1,10 @@ lockManager = $lockManager ?: \Magento\Framework\App\ObjectManager::getInstance()->get( \Magento\Framework\Lock\LockManagerInterface::class ); @@ -86,18 +89,21 @@ public function __construct( */ public function getIndexerId() { - return parent::getIndexerId(); + $id = parent::getIndexerId(); + return $id; } /** * Set indexer id * * @param string $value + * * @return $this */ public function setIndexerId($value) { - return parent::setIndexerId($value); + $self = parent::setIndexerId($value); + return $self; } /** @@ -108,8 +114,7 @@ public function setIndexerId($value) public function getStatus() { if ($this->isUseApplicationLock()) { - if ( - parent::getStatus() == StateInterface::STATUS_WORKING && + if (parent::getStatus() == StateInterface::STATUS_WORKING && !$this->lockManager->isLocked($this->lockPrefix . $this->getIndexerId()) ) { return StateInterface::STATUS_INVALID; @@ -126,24 +131,28 @@ public function getStatus() */ public function getUpdated() { - return parent::getUpdated(); + $updated = parent::getUpdated(); + return $updated; } /** * Set updated * * @param string $value + * * @return $this */ public function setUpdated($value) { - return parent::setUpdated($value); + $self = parent::setUpdated($value); + return $self; } /** * Fill object with state data by view ID * * @param string $indexerId + * * @return $this */ public function loadByIndexer($indexerId) @@ -159,6 +168,7 @@ public function loadByIndexer($indexerId) * Status setter * * @param string $status + * * @return $this */ public function setStatus($status) @@ -170,6 +180,7 @@ public function setStatus($status) $this->lockManager->unlock($this->lockPrefix . $this->getIndexerId()); } } + return parent::setStatus($status); } @@ -189,8 +200,8 @@ public function beforeSave() * * @return bool */ - private function isUseApplicationLock() + private function isUseApplicationLock(): bool { - return $this->configReader->get($this->useApplicationLockConfig) ?: false; + return (bool) ($this->configReader->get($this->useApplicationLockConfig) ?? true); } } diff --git a/app/code/Magento/Indexer/Model/Mview/View/State.php b/app/code/Magento/Indexer/Model/Mview/View/State.php index 66cc423f189c7..a943f8c9cbddc 100644 --- a/app/code/Magento/Indexer/Model/Mview/View/State.php +++ b/app/code/Magento/Indexer/Model/Mview/View/State.php @@ -150,8 +150,7 @@ public function getStatus() { $status = $this->getData('status'); if ($this->isUseApplicationLock()) { - if ( - $status == \Magento\Framework\Mview\View\StateInterface::STATUS_WORKING && + if ($status == \Magento\Framework\Mview\View\StateInterface::STATUS_WORKING && !$this->lockManager->isLocked($this->lockPrefix . $this->getViewId()) ) { return \Magento\Framework\Mview\View\StateInterface::STATUS_IDLE; @@ -229,8 +228,8 @@ public function setVersionId($versionId) * * @return bool */ - private function isUseApplicationLock() + private function isUseApplicationLock(): bool { - return $this->configReader->get($this->useApplicationLockConfig) ?: false; + return (bool) ($this->configReader->get($this->useApplicationLockConfig) ?? true); } }