Skip to content

Commit 160faa0

Browse files
authored
Merge pull request #527 from magento-performance/ACPT-1194-part1
ACPT-1194: Fixing bugs found by web api functional tests
2 parents 351c720 + 5fb1f5d commit 160faa0

File tree

12 files changed

+93
-34
lines changed

12 files changed

+93
-34
lines changed

app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\DB\Query\Generator as QueryGenerator;
1414
use Magento\Framework\DB\Select;
1515
use Magento\Framework\EntityManager\MetadataPool;
16+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1617
use Magento\Store\Api\Data\StoreInterface;
1718
use Magento\Store\Model\Store;
1819

@@ -25,7 +26,7 @@
2526
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2627
* @since 100.0.2
2728
*/
28-
abstract class AbstractAction
29+
abstract class AbstractAction implements ResetAfterRequestInterface
2930
{
3031
/**
3132
* Chunk size
@@ -156,6 +157,20 @@ public function __construct(
156157
$this->tableMaintainer = $tableMaintainer ?: ObjectManager::getInstance()->get(TableMaintainer::class);
157158
}
158159

160+
/**
161+
* @inheritDoc
162+
*/
163+
public function _resetState(): void
164+
{
165+
$this->nonAnchorSelects = [];
166+
$this->anchorSelects = [];
167+
$this->productsSelects = [];
168+
$this->categoryPath = [];
169+
$this->useTempTable = true;
170+
$this->tempTreeIndexTableName = null;
171+
$this->currentStore = null;
172+
}
173+
159174
/**
160175
* Run full reindex
161176
*

app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
use Magento\Catalog\Model\Attribute\ScopeOverriddenValue;
1111
use Magento\Catalog\Model\Product\Attribute\Backend\Price;
1212
use Magento\Customer\Api\GroupManagementInterface;
13+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1314

1415
/**
1516
* Catalog product abstract group price backend attribute model
1617
*
1718
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1819
*/
19-
abstract class AbstractGroupPrice extends Price
20+
abstract class AbstractGroupPrice extends Price implements ResetAfterRequestInterface
2021
{
2122
/**
2223
* @var \Magento\Framework\EntityManager\MetadataPool
@@ -26,7 +27,7 @@ abstract class AbstractGroupPrice extends Price
2627
/**
2728
* Website currency codes and rates
2829
*
29-
* @var array
30+
* @var array|null
3031
*/
3132
protected $_rates;
3233

@@ -39,8 +40,6 @@ abstract class AbstractGroupPrice extends Price
3940
abstract protected function _getDuplicateErrorMessage();
4041

4142
/**
42-
* Catalog product type
43-
*
4443
* @var \Magento\Catalog\Model\Product\Type
4544
*/
4645
protected $_catalogProductType;
@@ -82,6 +81,14 @@ public function __construct(
8281
);
8382
}
8483

84+
/**
85+
* @inheritdoc
86+
*/
87+
public function _resetState() : void
88+
{
89+
$this->_rates = null;
90+
}
91+
8592
/**
8693
* Retrieve websites currency rates and base currency codes
8794
*

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,5 +990,12 @@ public function _resetState(): void
990990
{
991991
$this->attributesPerSet = [];
992992
$this->_attributeData = [];
993+
foreach ($this->attributes ?? [] as $attributesGroupedByEntityTypeCode) {
994+
foreach ($attributesGroupedByEntityTypeCode as $attribute) {
995+
if ($attribute instanceof ResetAfterRequestInterface) {
996+
$attribute->_resetState();
997+
}
998+
}
999+
}
9931000
}
9941001
}

app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Framework\Api\AttributeValueFactory;
1111
use Magento\Framework\Exception\LocalizedException;
12+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1213
use Magento\Framework\Serialize\Serializer\Json;
1314

1415
/**
@@ -23,14 +24,15 @@
2324
*/
2425
abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractExtensibleModel implements
2526
AttributeInterface,
26-
\Magento\Eav\Api\Data\AttributeInterface
27+
\Magento\Eav\Api\Data\AttributeInterface,
28+
ResetAfterRequestInterface
2729
{
28-
const TYPE_STATIC = 'static';
30+
public const TYPE_STATIC = 'static';
2931

3032
/**
3133
* Const for empty string value.
3234
*/
33-
const EMPTY_STRING = '';
35+
public const EMPTY_STRING = '';
3436

3537
/**
3638
* Attribute name
@@ -68,8 +70,6 @@ abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractExtens
6870
protected $_source;
6971

7072
/**
71-
* Attribute id cache
72-
*
7373
* @var array
7474
*/
7575
protected $_attributeIdCache = [];
@@ -216,11 +216,19 @@ public function __construct(
216216
?: \Magento\Framework\App\ObjectManager::getInstance()->get(FrontendLabelFactory::class);
217217
}
218218

219+
/**
220+
* @inheritdoc
221+
*/
222+
public function _resetState() : void
223+
{
224+
if ($this->_backend instanceof ResetAfterRequestInterface) {
225+
$this->_backend->_resetState();
226+
}
227+
}
228+
219229
/**
220230
* Get Serializer instance.
221231
*
222-
* @deprecated 101.0.0
223-
*
224232
* @return Json
225233
* @since 101.0.0
226234
*/
@@ -229,7 +237,6 @@ protected function getSerializer()
229237
if ($this->serializer === null) {
230238
$this->serializer = \Magento\Framework\App\ObjectManager::getInstance()->create(Json::class);
231239
}
232-
233240
return $this->serializer;
234241
}
235242

@@ -930,6 +937,7 @@ public function _getFlatColumnsDdlDefinition()
930937
* Used in database compatible mode
931938
*
932939
* @deprecated 101.0.0
940+
* @see MMDB
933941
* @return array
934942
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
935943
*/

app/code/Magento/Store/Model/StoreManager.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
namespace Magento\Store\Model;
77

88
use Magento\Framework\App\ObjectManager;
9-
use Magento\Framework\Exception\NoSuchEntityException;
109
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1110
use Magento\Store\Api\StoreResolverInterface;
1211
use Magento\Store\Model\ResourceModel\StoreWebsiteRelation;

app/code/Magento/WeeeGraphQl/Model/Resolver/StoreConfig.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1111
use Magento\Framework\GraphQl\Config\Element\Field;
1212
use Magento\Framework\GraphQl\Query\ResolverInterface;
13+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1314
use Magento\Weee\Helper\Data;
1415
use Magento\Tax\Helper\Data as TaxHelper;
1516
use Magento\Store\Api\Data\StoreInterface;
@@ -19,7 +20,7 @@
1920
/**
2021
* Resolver for the FPT store config settings
2122
*/
22-
class StoreConfig implements ResolverInterface
23+
class StoreConfig implements ResolverInterface, ResetAfterRequestInterface
2324
{
2425
/**
2526
* @var string
@@ -61,6 +62,14 @@ public function __construct(Data $weeeHelper, TaxHelper $taxHelper)
6162
$this->taxHelper = $taxHelper;
6263
}
6364

65+
/**
66+
* @inheritDoc
67+
*/
68+
public function _resetState(): void
69+
{
70+
$this->computedFptSettings = [];
71+
}
72+
6473
/**
6574
* @inheritdoc
6675
*/

dev/tests/api-functional/testsuite/Magento/GraphQl/Newsletter/Guest/SubscribeEmailToNewsletterTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ protected function setUp(): void
3131
$this->subscriberResource = $objectManager->get(SubscriberResourceModel::class);
3232
}
3333

34+
/**
35+
* @magentoConfigFixture default_store newsletter/subscription/allow_guest_subscribe 1
36+
*/
3437
public function testAddEmailIntoNewsletterSubscription()
3538
{
3639
$query = $this->getQuery('[email protected]');
@@ -41,6 +44,9 @@ public function testAddEmailIntoNewsletterSubscription()
4144
self::assertEquals('SUBSCRIBED', $response['subscribeEmailToNewsletter']['status']);
4245
}
4346

47+
/**
48+
* @magentoConfigFixture default_store newsletter/subscription/allow_guest_subscribe 1
49+
*/
4450
public function testNewsletterSubscriptionWithIncorrectEmailFormat()
4551
{
4652
$query = $this->getQuery('guest.example.com');
@@ -68,6 +74,7 @@ public function testNewsletterSubscriptionWithDisallowedGuestSubscription()
6874

6975
/**
7076
* @magentoApiDataFixture Magento/Newsletter/_files/guest_subscriber.php
77+
* @magentoConfigFixture default_store newsletter/subscription/allow_guest_subscribe 1
7178
*/
7279
public function testNewsletterSubscriptionWithAlreadySubscribedEmail()
7380
{

dev/tests/api-functional/testsuite/Magento/GraphQl/PageCache/ProductInMultipleStoresCacheTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public function testProductFromSpecificAndDefaultStoreWithMultiCurrency()
230230
$this->assertEquals(
231231
'EUR',
232232
$response['products']['items'][0]['price']['minimalPrice']['amount']['currency'],
233-
'Currency code EUR in fixture ' . $storeCodeFromFixture . ' is unexpected'
233+
'Currency code EUR in fixture ' . $storeCodeFromFixture . ' is expected'
234234
);
235235

236236
// test cached store + currency header in Euros

lib/internal/Magento/Framework/Acl/Builder.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Framework\Acl;
77

8+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
9+
810
/**
911
* Access Control List Builder. Retrieves required role/rule/resource loaders
1012
* and uses them to populate provided ACL object. Acl object is put to cache after creation.
@@ -13,7 +15,7 @@
1315
* @api
1416
* @since 100.0.2
1517
*/
16-
class Builder
18+
class Builder implements ResetAfterRequestInterface
1719
{
1820
/**
1921
* Acl object
@@ -85,4 +87,12 @@ public function resetRuntimeAcl()
8587
$this->_acl = null;
8688
return $this;
8789
}
90+
91+
/**
92+
* @inheritdoc
93+
*/
94+
public function _resetState(): void
95+
{
96+
$this->resetRuntimeAcl();
97+
}
8898
}

lib/internal/Magento/Framework/App/ResourceConnection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ResourceConnection implements ResetAfterRequestInterface
4040
*
4141
* @var array
4242
*/
43-
protected $mappedTableNames;
43+
protected $mappedTableNames = [];
4444

4545
/**
4646
* Resource config.
@@ -89,6 +89,7 @@ public function __construct(
8989
*/
9090
public function _resetState() : void
9191
{
92+
$this->mappedTableNames = [];
9293
foreach ($this->connections as $connection) {
9394
if ($connection instanceof ResetAfterRequestInterface) {
9495
$connection->_resetState();

lib/internal/Magento/Framework/GraphQl/Query/QueryComplexityLimiter.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use GraphQL\Validator\Rules\QueryDepth;
1818
use GraphQL\Validator\Rules\QueryComplexity;
1919
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
20-
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
2120

2221
/**
2322
* QueryComplexityLimiter
@@ -28,7 +27,7 @@
2827
*
2928
* https://github.com/webonyx/graphql-php/blob/master/docs/security.md#query-complexity-analysis
3029
*/
31-
class QueryComplexityLimiter implements ResetAfterRequestInterface
30+
class QueryComplexityLimiter
3231
{
3332
/**
3433
* @var int
@@ -102,6 +101,7 @@ public function execute(): void
102101
*
103102
* @param string $query
104103
* @throws GraphQlInputException
104+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
105105
*/
106106
public function validateFieldCount(string $query): void
107107
{
@@ -118,7 +118,6 @@ public function validateFieldCount(string $query): void
118118
]
119119
]
120120
);
121-
122121
if ($totalFieldCount > $this->queryComplexity) {
123122
throw new GraphQlInputException(__(
124123
'Max query complexity should be %1 but got %2.',
@@ -128,16 +127,4 @@ public function validateFieldCount(string $query): void
128127
}
129128
}
130129
}
131-
132-
/**
133-
* @inheritDoc
134-
*/
135-
public function _resetState(): void
136-
{
137-
foreach ($this->getRules() as $rule) {
138-
DocumentValidator::removeRule($rule);
139-
unset($rule);
140-
};
141-
$this->rules = [];
142-
}
143130
}

lib/internal/Magento/Framework/Pricing/Price/Collection.php

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

77
namespace Magento\Framework\Pricing\Price;
88

9+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
910
use Magento\Framework\Pricing\SaleableInterface;
1011

1112
/**
@@ -14,7 +15,7 @@
1415
* @api
1516
* @since 100.0.2
1617
*/
17-
class Collection implements \Iterator
18+
class Collection implements \Iterator, ResetAfterRequestInterface
1819
{
1920
/**
2021
* @var Pool
@@ -74,6 +75,14 @@ public function __construct(
7475
$this->priceModels = [];
7576
}
7677

78+
/**
79+
* @inheritdoc
80+
*/
81+
public function _resetState() : void
82+
{
83+
$this->priceModels = [];
84+
}
85+
7786
/**
7887
* Reset the Collection to the first element
7988
*

0 commit comments

Comments
 (0)