From b099cb7f0e925e121d9fcdcaaf499bf3a0937358 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Fri, 3 Mar 2023 16:58:24 +0000 Subject: [PATCH 1/4] Enable indexer application locking by default --- app/code/Magento/Indexer/Model/Indexer/State.php | 4 ++-- app/code/Magento/Indexer/Model/Mview/View/State.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Indexer/Model/Indexer/State.php b/app/code/Magento/Indexer/Model/Indexer/State.php index 25fbcb7d15a53..866a34b9b7c10 100644 --- a/app/code/Magento/Indexer/Model/Indexer/State.php +++ b/app/code/Magento/Indexer/Model/Indexer/State.php @@ -189,8 +189,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..48ec70fe825dd 100644 --- a/app/code/Magento/Indexer/Model/Mview/View/State.php +++ b/app/code/Magento/Indexer/Model/Mview/View/State.php @@ -229,8 +229,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); } } From 32af65fc431393eb69c0799073b7aae09a9c2151 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Tue, 7 Mar 2023 18:25:09 +0000 Subject: [PATCH 2/4] Fix static test failures --- .../Magento/Indexer/Model/Indexer/State.php | 45 +------------------ .../Indexer/Model/Mview/View/State.php | 3 +- 2 files changed, 2 insertions(+), 46 deletions(-) diff --git a/app/code/Magento/Indexer/Model/Indexer/State.php b/app/code/Magento/Indexer/Model/Indexer/State.php index 866a34b9b7c10..9da41b4d4d5fc 100644 --- a/app/code/Magento/Indexer/Model/Indexer/State.php +++ b/app/code/Magento/Indexer/Model/Indexer/State.php @@ -79,27 +79,6 @@ public function __construct( parent::__construct($context, $registry, $resource, $resourceCollection, $data); } - /** - * Return indexer id - * - * @return string - */ - public function getIndexerId() - { - return parent::getIndexerId(); - } - - /** - * Set indexer id - * - * @param string $value - * @return $this - */ - public function setIndexerId($value) - { - return parent::setIndexerId($value); - } - /** * Return status * @@ -108,8 +87,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; @@ -119,27 +97,6 @@ public function getStatus() return parent::getStatus(); } - /** - * Return updated - * - * @return string - */ - public function getUpdated() - { - return parent::getUpdated(); - } - - /** - * Set updated - * - * @param string $value - * @return $this - */ - public function setUpdated($value) - { - return parent::setUpdated($value); - } - /** * Fill object with state data by view ID * diff --git a/app/code/Magento/Indexer/Model/Mview/View/State.php b/app/code/Magento/Indexer/Model/Mview/View/State.php index 48ec70fe825dd..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; From 419dcfda9d88441ae048b6798ace678b9f8be2c9 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Tue, 14 Mar 2023 16:58:31 +0000 Subject: [PATCH 3/4] Reinstate seemingly-useless functions --- .../Magento/Indexer/Model/Indexer/State.php | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/app/code/Magento/Indexer/Model/Indexer/State.php b/app/code/Magento/Indexer/Model/Indexer/State.php index 9da41b4d4d5fc..7e259d410884e 100644 --- a/app/code/Magento/Indexer/Model/Indexer/State.php +++ b/app/code/Magento/Indexer/Model/Indexer/State.php @@ -79,6 +79,27 @@ public function __construct( parent::__construct($context, $registry, $resource, $resourceCollection, $data); } + /** + * Return indexer id + * + * @return string + */ + public function getIndexerId() + { + return parent::getIndexerId(); + } + + /** + * Set indexer id + * + * @param string $value + * @return $this + */ + public function setIndexerId($value) + { + return parent::setIndexerId($value); + } + /** * Return status * @@ -97,6 +118,27 @@ public function getStatus() return parent::getStatus(); } + /** + * Return updated + * + * @return string + */ + public function getUpdated() + { + return parent::getUpdated(); + } + + /** + * Set updated + * + * @param string $value + * @return $this + */ + public function setUpdated($value) + { + return parent::setUpdated($value); + } + /** * Fill object with state data by view ID * From 182f08bee6748a1db9974d924e8e2a234720dc2a Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Wed, 22 Mar 2023 17:23:26 +0000 Subject: [PATCH 4/4] Fix static test failures --- .../Magento/Indexer/Model/Indexer/State.php | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Indexer/Model/Indexer/State.php b/app/code/Magento/Indexer/Model/Indexer/State.php index 7e259d410884e..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; } /** @@ -125,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) @@ -158,6 +168,7 @@ public function loadByIndexer($indexerId) * Status setter * * @param string $status + * * @return $this */ public function setStatus($status) @@ -169,6 +180,7 @@ public function setStatus($status) $this->lockManager->unlock($this->lockPrefix . $this->getIndexerId()); } } + return parent::setStatus($status); }