Skip to content

Commit

Permalink
Merge pull request #555 from magento-performance/ACPT-1480
Browse files Browse the repository at this point in the history
ACPT-1480: Implement _resetState for classes found by GraphQlB2BStateTest
  • Loading branch information
andimov authored Jul 25, 2023
2 parents 92fa2db + 724141b commit 5102223
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 9 deletions.
12 changes: 11 additions & 1 deletion app/code/Magento/Catalog/Helper/Product/Flat/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Magento\Catalog\Helper\Product\Flat;

use Magento\Framework\App\ResourceConnection;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;

/**
* Catalog Product Flat Indexer Helper
Expand All @@ -15,7 +16,7 @@
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @since 100.0.2
*/
class Indexer extends \Magento\Framework\App\Helper\AbstractHelper
class Indexer extends \Magento\Framework\App\Helper\AbstractHelper implements ResetAfterRequestInterface
{
/**
* Path to list of attributes used for flat indexer
Expand Down Expand Up @@ -515,4 +516,13 @@ public function deleteAbandonedStoreFlatTables()
$connection->dropTable($table);
}
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
$this->_entityTypeId = null;
$this->_flatAttributeGroups = [];
}
}
11 changes: 10 additions & 1 deletion app/code/Magento/Customer/Model/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Magento\Framework\Exception\EmailNotConfirmedException;
use Magento\Framework\Exception\InvalidEmailOrPasswordException;
use Magento\Framework\Indexer\StateInterface;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
use Magento\Framework\Reflection\DataObjectProcessor;
use Magento\Store\Model\ScopeInterface;
use Magento\Framework\App\ObjectManager;
Expand Down Expand Up @@ -45,7 +46,7 @@
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @since 100.0.2
*/
class Customer extends \Magento\Framework\Model\AbstractModel
class Customer extends \Magento\Framework\Model\AbstractModel implements ResetAfterRequestInterface
{
/**
* Configuration paths for email templates and identities
Expand Down Expand Up @@ -1403,4 +1404,12 @@ public function getPassword()
{
return (string) $this->getData('password');
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
$this->_errors = [];
}
}
12 changes: 11 additions & 1 deletion app/code/Magento/Eav/Model/AttributeDataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

namespace Magento\Eav\Model;

use Magento\Framework\ObjectManager\ResetAfterRequestInterface;

/**
* EAV Entity Attribute Data Factory
*
* @author Magento Core Team <core@magentocommerce.com>
*/
class AttributeDataFactory
class AttributeDataFactory implements ResetAfterRequestInterface
{
const OUTPUT_FORMAT_JSON = 'json';
const OUTPUT_FORMAT_TEXT = 'text';
Expand Down Expand Up @@ -85,4 +87,12 @@ public function create(\Magento\Eav\Model\Attribute $attribute, \Magento\Framewo

return $dataModel;
}

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

namespace Magento\Newsletter\Model;

use Magento\Framework\ObjectManager\ResetAfterRequestInterface;

/**
* This service provides caching Subscriber by Customer id.
*/
class CustomerSubscriberCache
class CustomerSubscriberCache implements ResetAfterRequestInterface
{
/**
* @var array
Expand Down Expand Up @@ -43,4 +45,12 @@ public function setCustomerSubscriber(int $customerId, ?Subscriber $subscriber):
{
$this->customerSubscriber[$customerId] = $subscriber;
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
$this->customerSubscriber = [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

use Magento\Framework\App\ObjectManager;
use Magento\Framework\ObjectManager\ConfigInterface;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;

/**
* @deprecated 100.1.0
*/
class CartItemProcessorsPool
class CartItemProcessorsPool implements ResetAfterRequestInterface
{
/**
* @var CartItemProcessorInterface[]
Expand Down Expand Up @@ -57,4 +58,12 @@ public function getCartItemProcessors()

return $this->cartItemProcessors;
}

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

use Magento\Framework\App\ResourceConnection as AppResource;
use Magento\Framework\DB\Ddl\Sequence as DdlSequence;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
use Magento\Framework\Webapi\Exception;
use Magento\SalesSequence\Model\ResourceModel\Meta as ResourceMetadata;
use Psr\Log\LoggerInterface as Logger;
Expand All @@ -18,7 +19,7 @@
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @since 100.0.2
*/
class Builder
class Builder implements ResetAfterRequestInterface
{
/**
* @var resourceMetadata
Expand Down Expand Up @@ -264,4 +265,12 @@ public function create()
}
$this->data = array_flip($this->pattern);
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
$this->data = [];
}
}
12 changes: 11 additions & 1 deletion app/code/Magento/Store/Model/Config/Processor/Fallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\TableNotFoundException;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
use Magento\Store\App\Config\Type\Scopes;
use Magento\Store\Model\ResourceModel\Store;
use Magento\Store\Model\ResourceModel\Store\AllStoresCollectionFactory;
Expand All @@ -19,7 +20,7 @@
/**
* Fallback through different scopes and merge them
*/
class Fallback implements PostProcessorInterface
class Fallback implements PostProcessorInterface, ResetAfterRequestInterface
{
/**
* @var Scopes
Expand Down Expand Up @@ -192,4 +193,13 @@ private function loadScopes(): void
$this->websiteData = [];
}
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
$this->storeData = [];
$this->websiteData = [];
}
}
11 changes: 10 additions & 1 deletion app/code/Magento/Weee/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
namespace Magento\Weee\Helper;

use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
use Magento\Sales\Model\Order\Item as OrderItem;
use Magento\Quote\Model\Quote\Item\AbstractItem as QuoteAbstractItem;
use Magento\Store\Model\Store;
Expand All @@ -19,7 +20,7 @@
* @api
* @since 100.0.2
*/
class Data extends \Magento\Framework\App\Helper\AbstractHelper
class Data extends \Magento\Framework\App\Helper\AbstractHelper implements ResetAfterRequestInterface
{
/**#@+
* Constants defined for keys of array, makes typos less likely
Expand Down Expand Up @@ -872,4 +873,12 @@ public function getWeeeAttributesForBundle($product)
}
return [];
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
$this->_storeDisplayConfig = [];
}
}
11 changes: 10 additions & 1 deletion lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\SerializationException;
use Magento\Framework\ObjectManager\ConfigInterface;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Phrase;
use Magento\Framework\Reflection\MethodsMap;
Expand All @@ -32,7 +33,7 @@
* @api
* @since 100.0.2
*/
class ServiceInputProcessor implements ServicePayloadConverterInterface
class ServiceInputProcessor implements ServicePayloadConverterInterface, ResetAfterRequestInterface
{
public const EXTENSION_ATTRIBUTES_TYPE = \Magento\Framework\Api\ExtensionAttributesInterface::class;

Expand Down Expand Up @@ -575,4 +576,12 @@ protected function processInputError($inputError)
}
}
}

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

0 comments on commit 5102223

Please sign in to comment.