Skip to content

Commit cd23b13

Browse files
committed
ACPT-1052: Some Luma Storefront Scenarios Are Broken
1 parent 73b7b4e commit cd23b13

File tree

15 files changed

+158
-17
lines changed

15 files changed

+158
-17
lines changed

app/code/Magento/Catalog/Model/Layer.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Catalog\Api\CategoryRepositoryInterface;
99
use Magento\Framework\Exception\NoSuchEntityException;
1010
use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory;
11+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1112

1213
/**
1314
* Catalog view layer model
@@ -17,7 +18,7 @@
1718
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1819
* @since 100.0.2
1920
*/
20-
class Layer extends \Magento\Framework\DataObject
21+
class Layer extends \Magento\Framework\DataObject implements ResetAfterRequestInterface
2122
{
2223
/**
2324
* Product collections array
@@ -266,4 +267,12 @@ public function getState()
266267

267268
return $state;
268269
}
270+
271+
/**
272+
* @inheritDoc
273+
*/
274+
public function _resetState(): void
275+
{
276+
$this->_productCollections = [];
277+
}
269278
}

app/code/Magento/CatalogGraphQl/Model/AttributesJoiner.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
use GraphQL\Language\AST\NodeKind;
1313
use Magento\Eav\Model\Entity\Collection\AbstractCollection;
1414
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
15+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1516

1617
/**
1718
* Joins attributes for provided field node field names.
1819
*/
19-
class AttributesJoiner
20+
class AttributesJoiner implements ResetAfterRequestInterface
2021
{
2122
/**
2223
* @var array
@@ -177,4 +178,12 @@ private function setSelectionsForFieldNode(FieldNode $fieldNode, array $selected
177178
{
178179
$this->queryFields[$fieldNode->name->value][$fieldNode->name->loc->start] = $selectedFields;
179180
}
181+
182+
/**
183+
* @inheritDoc
184+
*/
185+
public function _resetState(): void
186+
{
187+
$this->queryFields = [];
188+
}
180189
}

app/code/Magento/Cms/Model/Page/IdentityMap.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
namespace Magento\Cms\Model\Page;
99

1010
use Magento\Cms\Model\Page;
11+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1112

1213
/**
1314
* Identity map of loaded pages.
1415
*/
15-
class IdentityMap
16+
class IdentityMap implements ResetAfterRequestInterface
1617
{
1718
/**
1819
* @var Page[]
@@ -69,4 +70,12 @@ public function clear(): void
6970
{
7071
$this->pages = [];
7172
}
73+
74+
/**
75+
* @inheritDoc
76+
*/
77+
public function _resetState(): void
78+
{
79+
$this->pages = [];
80+
}
7281
}

app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableOptionsProvider.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
use Magento\Catalog\Api\Data\ProductInterface;
1010
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
1111
use Magento\Framework\App\ObjectManager;
12+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1213

1314
/**
1415
* Provide configurable child products for price calculation
1516
*/
16-
class ConfigurableOptionsProvider implements ConfigurableOptionsProviderInterface
17+
class ConfigurableOptionsProvider implements ConfigurableOptionsProviderInterface, ResetAfterRequestInterface
1718
{
1819
/**
1920
* @var Configurable
@@ -56,4 +57,12 @@ public function getProducts(ProductInterface $product)
5657
}
5758
return $this->products[$product->getId()];
5859
}
60+
61+
/**
62+
* @inheritDoc
63+
*/
64+
public function _resetState(): void
65+
{
66+
$this->products = [];
67+
}
5968
}

app/code/Magento/GraphQlCache/Model/CacheableQuery.php

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

88
namespace Magento\GraphQlCache\Model;
99

10+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
11+
1012
/**
1113
* CacheableQuery should be used as a singleton for collecting HTTP cache-related info and tags of all entities.
1214
*/
13-
class CacheableQuery
15+
class CacheableQuery implements ResetAfterRequestInterface
1416
{
1517
/**
1618
* @var string[]
@@ -75,4 +77,13 @@ public function shouldPopulateCacheHeadersWithTags() : bool
7577

7678
return !empty($cacheTags) && $isQueryCacheable;
7779
}
80+
81+
/**
82+
* @inheritDoc
83+
*/
84+
public function _resetState(): void
85+
{
86+
$this->cacheTags = [];
87+
$this->cacheable = true;
88+
}
7889
}

app/code/Magento/UrlRewrite/Model/UrlRewrite.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\Model\AbstractModel;
1515
use Magento\Framework\Model\Context;
1616
use Magento\Framework\Model\ResourceModel\AbstractResource;
17+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1718
use Magento\Framework\Registry;
1819
use Magento\Framework\Serialize\Serializer\Json;
1920
use Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite;
@@ -40,7 +41,7 @@
4041
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
4142
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
4243
*/
43-
class UrlRewrite extends AbstractModel
44+
class UrlRewrite extends AbstractModel implements ResetAfterRequestInterface
4445
{
4546
/**
4647
* @var Json
@@ -235,4 +236,12 @@ public function afterSave()
235236
$this->_getResource()->addCommitCallback([$this, 'cleanEntitiesCache']);
236237
return parent::afterSave();
237238
}
239+
240+
/**
241+
* @inheritDoc
242+
*/
243+
public function _resetState(): void
244+
{
245+
$this->entityToCacheTagMap = [];
246+
}
238247
}

dev/tests/api-functional/framework/Magento/TestFramework/Annotation/ApiConfigFixture.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\TestFramework\App\ApiMutableScopeConfig;
1616
use Magento\TestFramework\Config\Model\ConfigStorage;
1717
use Magento\TestFramework\Helper\Bootstrap;
18+
use PHPUnit\Framework\TestCase;
1819

1920
/**
2021
* @inheritDoc
@@ -57,6 +58,20 @@ protected function setStoreConfigValue(array $matches, $configPathAndValue): voi
5758
parent::setStoreConfigValue($matches, $configPathAndValue);
5859
}
5960

61+
/**
62+
* @inheritDoc
63+
*/
64+
protected function _assignConfigData(TestCase $test)
65+
{
66+
parent::_assignConfigData($test);
67+
$needUpdates = !empty($this->globalConfigValues)
68+
|| !empty($this->storeConfigValues)
69+
|| !empty($this->websiteConfigValues);
70+
if ($needUpdates) {
71+
$this->putPill();
72+
}
73+
}
74+
6075
/**
6176
* @inheritdoc
6277
*/
@@ -99,6 +114,9 @@ protected function setWebsiteConfigValue(array $matches, $configPathAndValue): v
99114
*/
100115
protected function _restoreConfigData()
101116
{
117+
$needUpdates = !empty($this->globalConfigValues)
118+
|| !empty($this->storeConfigValues)
119+
|| !empty($this->websiteConfigValues);
102120
/** @var ConfigResource $configResource */
103121
$configResource = Bootstrap::getObjectManager()->get(ConfigResource::class);
104122
/* Restore global values */
@@ -145,8 +163,10 @@ protected function _restoreConfigData()
145163
}
146164
}
147165
}
148-
$this->putPill();
149166
$this->websiteConfigValues = [];
167+
if ($needUpdates) {
168+
$this->putPill();
169+
}
150170

151171
}
152172

lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php

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

88
namespace Magento\Framework\Api;
99

10+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
11+
1012
/**
1113
* Base Builder Class for simple data Objects
1214
* @deprecated 103.0.0 Every builder should have their own implementation of \Magento\Framework\Api\SimpleBuilderInterface
1315
* @SuppressWarnings(PHPMD.NumberOfChildren)
1416
*/
15-
abstract class AbstractSimpleObjectBuilder implements SimpleBuilderInterface
17+
abstract class AbstractSimpleObjectBuilder implements SimpleBuilderInterface, ResetAfterRequestInterface
1618
{
1719
/**
1820
* @var array
@@ -85,4 +87,12 @@ public function getData()
8587
{
8688
return $this->data;
8789
}
90+
91+
/**
92+
* @inheritDoc
93+
*/
94+
public function _resetState(): void
95+
{
96+
$this->data = [];
97+
}
8898
}

lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
namespace Magento\Framework\Api;
1010

1111
use Magento\Framework\Api\Search\FilterGroupBuilder;
12+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1213

1314
/**
1415
* Builder for SearchCriteria Service Data Object
1516
*
1617
* @api
1718
*/
18-
class SearchCriteriaBuilder extends AbstractSimpleObjectBuilder
19+
class SearchCriteriaBuilder extends AbstractSimpleObjectBuilder implements ResetAfterRequestInterface
1920
{
2021
/**
2122
* @var FilterGroupBuilder
@@ -145,4 +146,12 @@ public function setCurrentPage($currentPage)
145146
{
146147
return $this->_set(SearchCriteria::CURRENT_PAGE, $currentPage);
147148
}
149+
150+
/**
151+
* @inheritDoc
152+
*/
153+
public function _resetState(): void
154+
{
155+
$this->data = [];
156+
}
148157
}

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

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

8+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
9+
810
/**
911
* Request processing flag that allows to stop request dispatching in action controller from an observer
1012
* Downside of this approach is temporal coupling and global communication.
@@ -15,7 +17,7 @@
1517
* @api
1618
* @since 100.0.2
1719
*/
18-
class ActionFlag
20+
class ActionFlag implements ResetAfterRequestInterface
1921
{
2022
/**
2123
* @var RequestInterface
@@ -83,4 +85,14 @@ protected function _getControllerKey()
8385
{
8486
return $this->_request->getRouteName() . '_' . $this->_request->getControllerName();
8587
}
88+
89+
/**
90+
* @inheritDoc
91+
*/
92+
public function _resetState(): void
93+
{
94+
$this->_flags = [];
95+
}
96+
97+
8698
}

0 commit comments

Comments
 (0)