Skip to content

Commit

Permalink
Merge branch '2.4-develop' into Fix-cron-schedule-deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
ihor-sviziev authored Aug 21, 2020
2 parents 96029b5 + 8b7d949 commit 7df183b
Show file tree
Hide file tree
Showing 158 changed files with 2,504 additions and 1,042 deletions.
35 changes: 18 additions & 17 deletions app/code/Magento/Catalog/Model/CategoryLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,41 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Model;

use Magento\Catalog\Api\Data\CategoryLinkExtensionInterface;
use Magento\Catalog\Api\Data\CategoryLinkInterface;
use Magento\Framework\Model\AbstractExtensibleModel;

/**
* @codeCoverageIgnore
*/
class CategoryLink extends \Magento\Framework\Api\AbstractExtensibleObject implements
\Magento\Catalog\Api\Data\CategoryLinkInterface
class CategoryLink extends AbstractExtensibleModel implements CategoryLinkInterface
{
/**#@+
* Constants
*/
const KEY_POSITION = 'position';
const KEY_CATEGORY_ID = 'category_id';
/**#@-*/
public const KEY_POSITION = 'position';
public const KEY_CATEGORY_ID = 'category_id';

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getPosition()
{
return $this->_get(self::KEY_POSITION);
return $this->getData(self::KEY_POSITION);
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getCategoryId()
{
return $this->_get(self::KEY_CATEGORY_ID);
return $this->getData(self::KEY_CATEGORY_ID);
}

/**
* @inheritDoc
*
* @param int $position
* @return $this
*/
Expand All @@ -56,7 +58,7 @@ public function setCategoryId($categoryId)
}

/**
* {@inheritdoc}
* @inheritdoc
*
* @return \Magento\Catalog\Api\Data\CategoryLinkExtensionInterface|null
*/
Expand All @@ -66,14 +68,13 @@ public function getExtensionAttributes()
}

/**
* {@inheritdoc}
* @inheritdoc
*
* @param \Magento\Catalog\Api\Data\CategoryLinkExtensionInterface $extensionAttributes
* @return $this
*/
public function setExtensionAttributes(
\Magento\Catalog\Api\Data\CategoryLinkExtensionInterface $extensionAttributes
) {
public function setExtensionAttributes(CategoryLinkExtensionInterface $extensionAttributes)
{
return $this->_setExtensionAttributes($extensionAttributes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@
*/
namespace Magento\Catalog\Model\Indexer\Category\Flat\Plugin;

use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Catalog\Model\Indexer\Category\Flat\State;
use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;

class StoreGroup
{
/**
* @var bool
*/
private $needInvalidating;

/**
* @var IndexerRegistry
*/
Expand Down Expand Up @@ -48,35 +43,21 @@ protected function validate(AbstractModel $group)
return $group->dataHasChangedFor('root_category_id') && !$group->isObjectNew();
}

/**
* Check if need invalidate flat category indexer
*
* @param AbstractDb $subject
* @param AbstractModel $group
*
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(AbstractDb $subject, AbstractModel $group)
{
$this->needInvalidating = $this->validate($group);
}

/**
* Invalidate flat category indexer if root category changed for store group
*
* @param AbstractDb $subject
* @param AbstractDb $objectResource
*
* @param AbstractDb $result
* @param AbstractModel $group
* @return AbstractDb
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterSave(AbstractDb $subject, AbstractDb $objectResource)
public function afterSave(AbstractDb $subject, AbstractDb $result, AbstractModel $group)
{
if ($this->needInvalidating && $this->state->isFlatEnabled()) {
if ($this->validate($group) && $this->state->isFlatEnabled()) {
$this->indexerRegistry->get(State::INDEXER_ID)->invalidate();
}

return $objectResource;
return $result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@
*/
namespace Magento\Catalog\Model\Indexer\Category\Product\Plugin;

use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\Model\AbstractModel;
use Magento\Catalog\Model\Indexer\Category\Product;
use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer;
use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;

class StoreGroup
{
/**
* @var bool
*/
private $needInvalidating;

/**
* @var IndexerRegistry
*/
Expand All @@ -40,36 +35,23 @@ public function __construct(
$this->tableMaintainer = $tableMaintainer;
}

/**
* Check if need invalidate flat category indexer
*
* @param AbstractDb $subject
* @param AbstractModel $group
*
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(AbstractDb $subject, AbstractModel $group)
{
$this->needInvalidating = $this->validate($group);
}

/**
* Invalidate flat product
*
* @param AbstractDb $subject
* @param AbstractDb $objectResource
* @param AbstractDb $result
* @param AbstractModel $group
*
* @return AbstractDb
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterSave(AbstractDb $subject, AbstractDb $objectResource)
public function afterSave(AbstractDb $subject, AbstractDb $result, AbstractModel $group)
{
if ($this->needInvalidating) {
if ($this->validate($group)) {
$this->indexerRegistry->get(Product::INDEXER_ID)->invalidate();
}

return $objectResource;
return $result;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
*/
namespace Magento\Catalog\Model\Indexer\Category\Product\Plugin;

use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;

class StoreView extends StoreGroup
{
/**
* Validate changes for invalidating indexer
*
* @param \Magento\Framework\Model\AbstractModel $store
* @param AbstractModel $store
* @return bool
*/
protected function validate(\Magento\Framework\Model\AbstractModel $store)
protected function validate(AbstractModel $store)
{
return $store->isObjectNew() || $store->dataHasChangedFor('group_id');
}
Expand All @@ -36,7 +36,7 @@ public function afterSave(AbstractDb $subject, AbstractDb $objectResource, Abstr
$this->tableMaintainer->createTablesForStore($store->getId());
}

return parent::afterSave($subject, $objectResource);
return parent::afterSave($subject, $objectResource, $store);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,46 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Catalog\Model\Indexer\Product\Eav\Plugin;

use Magento\Catalog\Model\Indexer\Product\Eav\Processor;
use Magento\Framework\Model\AbstractModel;
use Magento\Store\Model\ResourceModel\Store;

class StoreView
{
/**
* Product attribute indexer processor
*
* @var \Magento\Catalog\Model\Indexer\Product\Eav\Processor
* @var Processor
*/
protected $_indexerEavProcessor;

/**
* @param \Magento\Catalog\Model\Indexer\Product\Eav\Processor $indexerEavProcessor
* @param Processor $indexerEavProcessor
*/
public function __construct(\Magento\Catalog\Model\Indexer\Product\Eav\Processor $indexerEavProcessor)
public function __construct(Processor $indexerEavProcessor)
{
$this->_indexerEavProcessor = $indexerEavProcessor;
}

/**
* Before save handler
*
* @param \Magento\Store\Model\ResourceModel\Store $subject
* @param \Magento\Framework\Model\AbstractModel $object
* @param Store $subject
* @param Store $result
* @param AbstractModel $object
*
* @return void
* @return Store
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(
\Magento\Store\Model\ResourceModel\Store $subject,
\Magento\Framework\Model\AbstractModel $object
) {
if ((!$object->getId() || $object->dataHasChangedFor('group_id')) && $object->getIsActive()) {
public function afterSave(Store $subject, Store $result, AbstractModel $object)
{
if (($object->isObjectNew() || $object->dataHasChangedFor('group_id')) && $object->getIsActive()) {
$this->_indexerEavProcessor->markIndexerAsInvalid();
}

return $result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,43 @@

namespace Magento\Catalog\Model\Indexer\Product\Flat\Plugin;

use Magento\Catalog\Model\Indexer\Product\Flat\Processor;
use Magento\Framework\Model\AbstractModel;
use Magento\Store\Model\ResourceModel\Store as StoreResourceModel;

class Store
{
/**
* Product flat indexer processor
*
* @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor
* @var Processor
*/
protected $_productFlatIndexerProcessor;

/**
* @param \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor
* @param Processor $productFlatIndexerProcessor
*/
public function __construct(\Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor)
public function __construct(Processor $productFlatIndexerProcessor)
{
$this->_productFlatIndexerProcessor = $productFlatIndexerProcessor;
}

/**
* Before save handler
*
* @param \Magento\Store\Model\ResourceModel\Store $subject
* @param \Magento\Framework\Model\AbstractModel $object
* @param StoreResourceModel $subject
* @param StoreResourceModel $result
* @param AbstractModel $object
*
* @return void
* @return StoreResourceModel
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(
\Magento\Store\Model\ResourceModel\Store $subject,
\Magento\Framework\Model\AbstractModel $object
) {
if (!$object->getId() || $object->dataHasChangedFor('group_id')) {
public function afterSave(StoreResourceModel $subject, StoreResourceModel $result, AbstractModel $object)
{
if ($object->isObjectNew() || $object->dataHasChangedFor('group_id')) {
$this->_productFlatIndexerProcessor->markIndexerAsInvalid();
}

return $result;
}
}
Loading

0 comments on commit 7df183b

Please sign in to comment.