Skip to content

Commit 5102223

Browse files
authored
Merge pull request #555 from magento-performance/ACPT-1480
ACPT-1480: Implement _resetState for classes found by GraphQlB2BStateTest
2 parents 92fa2db + 724141b commit 5102223

File tree

9 files changed

+94
-9
lines changed

9 files changed

+94
-9
lines changed

app/code/Magento/Catalog/Helper/Product/Flat/Indexer.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Catalog\Helper\Product\Flat;
77

88
use Magento\Framework\App\ResourceConnection;
9+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
910

1011
/**
1112
* Catalog Product Flat Indexer Helper
@@ -15,7 +16,7 @@
1516
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1617
* @since 100.0.2
1718
*/
18-
class Indexer extends \Magento\Framework\App\Helper\AbstractHelper
19+
class Indexer extends \Magento\Framework\App\Helper\AbstractHelper implements ResetAfterRequestInterface
1920
{
2021
/**
2122
* Path to list of attributes used for flat indexer
@@ -515,4 +516,13 @@ public function deleteAbandonedStoreFlatTables()
515516
$connection->dropTable($table);
516517
}
517518
}
519+
520+
/**
521+
* @inheritDoc
522+
*/
523+
public function _resetState(): void
524+
{
525+
$this->_entityTypeId = null;
526+
$this->_flatAttributeGroups = [];
527+
}
518528
}

app/code/Magento/Customer/Model/Customer.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\Framework\Exception\EmailNotConfirmedException;
1818
use Magento\Framework\Exception\InvalidEmailOrPasswordException;
1919
use Magento\Framework\Indexer\StateInterface;
20+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
2021
use Magento\Framework\Reflection\DataObjectProcessor;
2122
use Magento\Store\Model\ScopeInterface;
2223
use Magento\Framework\App\ObjectManager;
@@ -45,7 +46,7 @@
4546
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
4647
* @since 100.0.2
4748
*/
48-
class Customer extends \Magento\Framework\Model\AbstractModel
49+
class Customer extends \Magento\Framework\Model\AbstractModel implements ResetAfterRequestInterface
4950
{
5051
/**
5152
* Configuration paths for email templates and identities
@@ -1403,4 +1404,12 @@ public function getPassword()
14031404
{
14041405
return (string) $this->getData('password');
14051406
}
1407+
1408+
/**
1409+
* @inheritDoc
1410+
*/
1411+
public function _resetState(): void
1412+
{
1413+
$this->_errors = [];
1414+
}
14061415
}

app/code/Magento/Eav/Model/AttributeDataFactory.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66

77
namespace Magento\Eav\Model;
88

9+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
10+
911
/**
1012
* EAV Entity Attribute Data Factory
1113
*
1214
* @author Magento Core Team <core@magentocommerce.com>
1315
*/
14-
class AttributeDataFactory
16+
class AttributeDataFactory implements ResetAfterRequestInterface
1517
{
1618
const OUTPUT_FORMAT_JSON = 'json';
1719
const OUTPUT_FORMAT_TEXT = 'text';
@@ -85,4 +87,12 @@ public function create(\Magento\Eav\Model\Attribute $attribute, \Magento\Framewo
8587

8688
return $dataModel;
8789
}
90+
91+
/**
92+
* @inheritDoc
93+
*/
94+
public function _resetState(): void
95+
{
96+
$this->_dataModels = [];
97+
}
8898
}

app/code/Magento/Newsletter/Model/CustomerSubscriberCache.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77

88
namespace Magento\Newsletter\Model;
99

10+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
11+
1012
/**
1113
* This service provides caching Subscriber by Customer id.
1214
*/
13-
class CustomerSubscriberCache
15+
class CustomerSubscriberCache implements ResetAfterRequestInterface
1416
{
1517
/**
1618
* @var array
@@ -43,4 +45,12 @@ public function setCustomerSubscriber(int $customerId, ?Subscriber $subscriber):
4345
{
4446
$this->customerSubscriber[$customerId] = $subscriber;
4547
}
48+
49+
/**
50+
* @inheritDoc
51+
*/
52+
public function _resetState(): void
53+
{
54+
$this->customerSubscriber = [];
55+
}
4656
}

app/code/Magento/Quote/Model/Quote/Item/CartItemProcessorsPool.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77

88
use Magento\Framework\App\ObjectManager;
99
use Magento\Framework\ObjectManager\ConfigInterface;
10+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1011

1112
/**
1213
* @deprecated 100.1.0
1314
*/
14-
class CartItemProcessorsPool
15+
class CartItemProcessorsPool implements ResetAfterRequestInterface
1516
{
1617
/**
1718
* @var CartItemProcessorInterface[]
@@ -57,4 +58,12 @@ public function getCartItemProcessors()
5758

5859
return $this->cartItemProcessors;
5960
}
61+
62+
/**
63+
* @inheritDoc
64+
*/
65+
public function _resetState(): void
66+
{
67+
$this->cartItemProcessors = [];
68+
}
6069
}

app/code/Magento/SalesSequence/Model/Builder.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Framework\App\ResourceConnection as AppResource;
99
use Magento\Framework\DB\Ddl\Sequence as DdlSequence;
10+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1011
use Magento\Framework\Webapi\Exception;
1112
use Magento\SalesSequence\Model\ResourceModel\Meta as ResourceMetadata;
1213
use Psr\Log\LoggerInterface as Logger;
@@ -18,7 +19,7 @@
1819
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1920
* @since 100.0.2
2021
*/
21-
class Builder
22+
class Builder implements ResetAfterRequestInterface
2223
{
2324
/**
2425
* @var resourceMetadata
@@ -264,4 +265,12 @@ public function create()
264265
}
265266
$this->data = array_flip($this->pattern);
266267
}
268+
269+
/**
270+
* @inheritDoc
271+
*/
272+
public function _resetState(): void
273+
{
274+
$this->data = [];
275+
}
267276
}

app/code/Magento/Store/Model/Config/Processor/Fallback.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\App\DeploymentConfig;
1010
use Magento\Framework\App\ResourceConnection;
1111
use Magento\Framework\DB\Adapter\TableNotFoundException;
12+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1213
use Magento\Store\App\Config\Type\Scopes;
1314
use Magento\Store\Model\ResourceModel\Store;
1415
use Magento\Store\Model\ResourceModel\Store\AllStoresCollectionFactory;
@@ -19,7 +20,7 @@
1920
/**
2021
* Fallback through different scopes and merge them
2122
*/
22-
class Fallback implements PostProcessorInterface
23+
class Fallback implements PostProcessorInterface, ResetAfterRequestInterface
2324
{
2425
/**
2526
* @var Scopes
@@ -192,4 +193,13 @@ private function loadScopes(): void
192193
$this->websiteData = [];
193194
}
194195
}
196+
197+
/**
198+
* @inheritDoc
199+
*/
200+
public function _resetState(): void
201+
{
202+
$this->storeData = [];
203+
$this->websiteData = [];
204+
}
195205
}

app/code/Magento/Weee/Helper/Data.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Weee\Helper;
77

8+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
89
use Magento\Sales\Model\Order\Item as OrderItem;
910
use Magento\Quote\Model\Quote\Item\AbstractItem as QuoteAbstractItem;
1011
use Magento\Store\Model\Store;
@@ -19,7 +20,7 @@
1920
* @api
2021
* @since 100.0.2
2122
*/
22-
class Data extends \Magento\Framework\App\Helper\AbstractHelper
23+
class Data extends \Magento\Framework\App\Helper\AbstractHelper implements ResetAfterRequestInterface
2324
{
2425
/**#@+
2526
* Constants defined for keys of array, makes typos less likely
@@ -872,4 +873,12 @@ public function getWeeeAttributesForBundle($product)
872873
}
873874
return [];
874875
}
876+
877+
/**
878+
* @inheritDoc
879+
*/
880+
public function _resetState(): void
881+
{
882+
$this->_storeDisplayConfig = [];
883+
}
875884
}

lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Framework\Exception\InputException;
1616
use Magento\Framework\Exception\SerializationException;
1717
use Magento\Framework\ObjectManager\ConfigInterface;
18+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1819
use Magento\Framework\ObjectManagerInterface;
1920
use Magento\Framework\Phrase;
2021
use Magento\Framework\Reflection\MethodsMap;
@@ -32,7 +33,7 @@
3233
* @api
3334
* @since 100.0.2
3435
*/
35-
class ServiceInputProcessor implements ServicePayloadConverterInterface
36+
class ServiceInputProcessor implements ServicePayloadConverterInterface, ResetAfterRequestInterface
3637
{
3738
public const EXTENSION_ATTRIBUTES_TYPE = \Magento\Framework\Api\ExtensionAttributesInterface::class;
3839

@@ -575,4 +576,12 @@ protected function processInputError($inputError)
575576
}
576577
}
577578
}
579+
580+
/**
581+
* @inheritDoc
582+
*/
583+
public function _resetState(): void
584+
{
585+
$this->attributesPreprocessorsMap = [];
586+
}
578587
}

0 commit comments

Comments
 (0)