Skip to content

Commit

Permalink
Merge pull request #526 from magento-performance/ACPT-1052-part3
Browse files Browse the repository at this point in the history
Acpt 1052 part3
  • Loading branch information
andimov authored May 3, 2023
2 parents a74f840 + 47b2005 commit 446fbd3
Show file tree
Hide file tree
Showing 47 changed files with 586 additions and 129 deletions.
20 changes: 11 additions & 9 deletions app/code/Magento/Catalog/Model/Layer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;

/**
* Catalog view layer model
Expand All @@ -17,7 +18,7 @@
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @since 100.0.2
*/
class Layer extends \Magento\Framework\DataObject
class Layer extends \Magento\Framework\DataObject implements ResetAfterRequestInterface
{
/**
* Product collections array
Expand All @@ -41,29 +42,21 @@ class Layer extends \Magento\Framework\DataObject
protected $registry = null;

/**
* Store manager
*
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $_storeManager;

/**
* Catalog product
*
* @var \Magento\Catalog\Model\ResourceModel\Product
*/
protected $_catalogProduct;

/**
* Attribute collection factory
*
* @var AttributeCollectionFactory
*/
protected $_attributeCollectionFactory;

/**
* Layer state factory
*
* @var \Magento\Catalog\Model\Layer\StateFactory
*/
protected $_layerStateFactory;
Expand Down Expand Up @@ -187,6 +180,7 @@ public function apply()

/**
* Retrieve current category model
*
* If no category found in registry, the root will be taken
*
* @return \Magento\Catalog\Model\Category
Expand Down Expand Up @@ -266,4 +260,12 @@ public function getState()

return $state;
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
$this->_productCollections = [];
}
}
11 changes: 10 additions & 1 deletion app/code/Magento/Catalog/Model/Product/Type/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Magento\Catalog\Model\Product;
use Magento\Customer\Api\GroupManagementInterface;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Store\Model\Store;
use Magento\Catalog\Api\Data\ProductTierPriceExtensionFactory;
Expand All @@ -23,7 +24,7 @@
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
* @since 100.0.2
*/
class Price
class Price implements ResetAfterRequestInterface
{
/**
* Product price cache tag
Expand Down Expand Up @@ -657,4 +658,12 @@ public function isTierPriceFixed()
{
return true;
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
self::$attributeCache = [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Magento\Catalog\Api\CategoryListInterface;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
use Magento\Framework\Search\Response\Aggregation;
use Magento\Framework\Search\Response\AggregationFactory;
use Magento\Framework\Search\Response\BucketFactory;
Expand All @@ -18,7 +19,7 @@
/**
* Class to include only direct subcategories of category in aggregation
*/
class IncludeDirectChildrenOnly
class IncludeDirectChildrenOnly implements ResetAfterRequestInterface
{
/**
* @var string
Expand Down Expand Up @@ -160,4 +161,12 @@ private function filterBucketValues(
}
return array_values($categoryBucketValues);
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
$this->filter = [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
use Magento\Framework\Api\Search\BucketInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\GraphQl\Query\Uid;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;

/**
* Category layer builder
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Category implements LayerBuilderInterface
class Category implements LayerBuilderInterface, ResetAfterRequestInterface
{
/**
* @var string
Expand Down Expand Up @@ -201,4 +202,17 @@ private function getStoreCategoryIds(int $storeId): array
);
return $collection->getAllIds();
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
self::$bucketMap = [
self::CATEGORY_BUCKET => [
'request_name' => 'category_uid',
'label' => 'Category'
],
];
}
}
11 changes: 10 additions & 1 deletion app/code/Magento/CatalogGraphQl/Model/AttributesJoiner.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
use GraphQL\Language\AST\NodeKind;
use Magento\Eav\Model\Entity\Collection\AbstractCollection;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;

/**
* Joins attributes for provided field node field names.
*/
class AttributesJoiner
class AttributesJoiner implements ResetAfterRequestInterface
{
/**
* @var array
Expand Down Expand Up @@ -177,4 +178,12 @@ private function setSelectionsForFieldNode(FieldNode $fieldNode, array $selected
{
$this->queryFields[$fieldNode->name->value][$fieldNode->name->loc->start] = $selectedFields;
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
$this->queryFields = [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,6 @@ public function _resetState(): void
{
$this->productList = [];
$this->productSkus = [];
$this->attributeCodes = [];
}
}
20 changes: 15 additions & 5 deletions app/code/Magento/CatalogRule/Model/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,28 @@
use Magento\Framework\Model\Context;
use Magento\Framework\Model\ResourceModel\AbstractResource;
use Magento\Framework\Model\ResourceModel\Iterator;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
use Magento\Framework\Registry;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\Stdlib\DateTime;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Rule\Model\AbstractModel;
use Magento\Store\Model\StoreManagerInterface;

/**
* Catalog Rule data model
*
* @method \Magento\CatalogRule\Model\Rule setFromDate(string $value)
* @method \Magento\CatalogRule\Model\Rule setToDate(string $value)
* @method \Magento\CatalogRule\Model\Rule setCustomerGroupIds(string $value)
* @method Rule setFromDate(string $value)
* @method Rule setToDate(string $value)
* @method Rule setCustomerGroupIds(string $value)
* @method string getWebsiteIds()
* @method \Magento\CatalogRule\Model\Rule setWebsiteIds(string $value)
* @method Rule setWebsiteIds(string $value)
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
*/
class Rule extends \Magento\Rule\Model\AbstractModel implements RuleInterface, IdentityInterface
class Rule extends AbstractModel implements RuleInterface, IdentityInterface, ResetAfterRequestInterface
{
/**
* Prefix of model events names
Expand Down Expand Up @@ -917,4 +919,12 @@ public function clearPriceRulesData(): void
{
self::$_priceRulesData = [];
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
self::$_priceRulesData = [];
}
}
11 changes: 10 additions & 1 deletion app/code/Magento/Cms/Model/Page/IdentityMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
namespace Magento\Cms\Model\Page;

use Magento\Cms\Model\Page;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;

/**
* Identity map of loaded pages.
*/
class IdentityMap
class IdentityMap implements ResetAfterRequestInterface
{
/**
* @var Page[]
Expand Down Expand Up @@ -69,4 +70,12 @@ public function clear(): void
{
$this->pages = [];
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
$this->pages = [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;

/**
* Provide configurable child products for price calculation
*/
class ConfigurableOptionsProvider implements ConfigurableOptionsProviderInterface
class ConfigurableOptionsProvider implements ConfigurableOptionsProviderInterface, ResetAfterRequestInterface
{
/**
* @var Configurable
Expand Down Expand Up @@ -56,4 +57,12 @@ public function getProducts(ProductInterface $product)
}
return $this->products[$product->getId()];
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
$this->products = [];
}
}
12 changes: 11 additions & 1 deletion app/code/Magento/Customer/Model/Address/AbstractAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Magento\Customer\Model\Data\Address as AddressData;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Model\AbstractExtensibleModel;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;

/**
* Address abstract model
Expand All @@ -35,7 +36,7 @@
* @api
* @since 100.0.2
*/
class AbstractAddress extends AbstractExtensibleModel implements AddressModelInterface
class AbstractAddress extends AbstractExtensibleModel implements AddressModelInterface, ResetAfterRequestInterface
{
/**
* Possible customer address types
Expand Down Expand Up @@ -736,4 +737,13 @@ private function processCustomAttribute(array $attribute): array

return $attribute;
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
self::$_countryModels = [];
self::$_regionModels = [];
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Customer/Model/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ public function isResetPasswordLinkTokenExpired()
}

$hourDifference = floor(($currentTimestamp - $tokenTimestamp) / (60 * 60));

return $hourDifference >= $expirationPeriod;
}

Expand Down
12 changes: 11 additions & 1 deletion app/code/Magento/Directory/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\Json\Helper\Data as JsonData;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;

Expand All @@ -26,7 +27,7 @@
* @since 100.0.2
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Data extends AbstractHelper
class Data extends AbstractHelper implements ResetAfterRequestInterface
{
private const STORE_ID = 'store_id';

Expand Down Expand Up @@ -435,4 +436,13 @@ private function getCurrentScope(): array

return $scope;
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
$this->_regionJson = null;
$this->_currencyCache = [];
}
}
Loading

0 comments on commit 446fbd3

Please sign in to comment.