Skip to content

Commit c54fd86

Browse files
authored
Merge branch '2.4-develop' into no-author/wishlist
2 parents 86b9056 + 8ea62ab commit c54fd86

File tree

17 files changed

+525
-822
lines changed

17 files changed

+525
-822
lines changed

app/code/Magento/Catalog/Test/Mftf/Test/TierPricingWhenPriceScopeIsWebsiteWorkingProperlyWithMultipleCurrenciesConfiguredTest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@
127127
<click selector="{{AdminNewWebsiteActionsSection.setAsDefault}}" stepKey="setNewWebsiteAsDefault"/>
128128
<click selector="{{AdminNewWebsiteActionsSection.saveWebsite}}" stepKey="clickSaveNewWebsite"/>
129129
<waitForPageLoad stepKey="waitForSuccess"/>
130+
<!-- Clean config and full page cache after making website a default one-->
131+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanCache">
132+
<argument name="tags" value="config full_page"/>
133+
</actionGroup>
130134
</before>
131135
<after>
132136
<magentoCLI command="config:set {{GlobalCatalogPriceScopeConfigData.path}} {{GlobalCatalogPriceScopeConfigData.value}}" stepKey="setPriceScopeGlobal"/>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\App\CacheInterface;
1414
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1515
use Magento\Framework\Serialize\SerializerInterface;
16+
use Magento\Store\Model\Store;
1617
use Magento\Store\Model\StoreManagerInterface;
1718

1819
/**
@@ -138,7 +139,8 @@ public function save($entityType, array $attributes, $suffix = '')
138139
[
139140
Type::CACHE_TAG,
140141
Attribute::CACHE_TAG,
141-
System::CACHE_TAG
142+
System::CACHE_TAG,
143+
Store::CACHE_TAG
142144
]
143145
);
144146
}

app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeMetadataCacheTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Magento\Framework\Serialize\SerializerInterface;
2020
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
2121
use Magento\Store\Api\Data\StoreInterface;
22+
use Magento\Store\Model\Store;
2223
use Magento\Store\Model\StoreManagerInterface;
2324
use PHPUnit\Framework\MockObject\MockObject;
2425
use PHPUnit\Framework\TestCase;
@@ -223,7 +224,8 @@ public function testSave(): void
223224
[
224225
Type::CACHE_TAG,
225226
Attribute::CACHE_TAG,
226-
System::CACHE_TAG
227+
System::CACHE_TAG,
228+
Store::CACHE_TAG
227229
]
228230
);
229231
$this->attributeMetadataCache->save($entityType, $attributesMetadata, $suffix);

app/code/Magento/Sales/Test/Mftf/Test/OrderDataGridDisplaysPurchaseDateTest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@
131131
<actionGroup ref="AdminSetDefaultWebsiteActionGroup" stepKey="setSecondWebsiteAsDefault">
132132
<argument name="websiteName" value="{{secondCustomWebsite.name}}"/>
133133
</actionGroup>
134+
<!-- Clean config and full page cache-->
135+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanCache">
136+
<argument name="tags" value="config full_page"/>
137+
</actionGroup>
134138
<!-- create second Customer-->
135139
<createData entity="Simple_US_Customer_CA" stepKey="createSecondCustomer"/>
136140
<!--Go to Storefront as Customer-->

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,17 @@ public function getIdentities()
512512
return [self::CACHE_TAG];
513513
}
514514

515+
/**
516+
* @inheritDoc
517+
*/
518+
public function getCacheTags()
519+
{
520+
$identities = $this->getIdentities();
521+
$parentTags = parent::getCacheTags();
522+
523+
return array_unique(array_merge($identities, $parentTags));
524+
}
525+
515526
/**
516527
* @inheritdoc
517528
*/

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,17 @@ public function getIdentities()
13651365
return [self::CACHE_TAG];
13661366
}
13671367

1368+
/**
1369+
* @inheritDoc
1370+
*/
1371+
public function getCacheTags()
1372+
{
1373+
$identities = $this->getIdentities();
1374+
$parentTags = parent::getCacheTags();
1375+
1376+
return array_unique(array_merge($identities, $parentTags));
1377+
}
1378+
13681379
/**
13691380
* Return Store Path
13701381
*

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,10 @@ public function getWebsites($withDefault = false, $codeKey = false)
236236
public function reinitStores()
237237
{
238238
$this->currentStoreId = null;
239-
$this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, [StoreResolver::CACHE_TAG, Store::CACHE_TAG]);
239+
$this->cache->clean(
240+
\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG,
241+
[StoreResolver::CACHE_TAG, Store::CACHE_TAG, Website::CACHE_TAG, Group::CACHE_TAG]
242+
);
240243
$this->scopeConfig->clean();
241244
$this->storeRepository->clean();
242245
$this->websiteRepository->clean();

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

Lines changed: 62 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@
55
*/
66
namespace Magento\Store\Model;
77

8+
use Magento\Config\Model\ResourceModel\Config\Data;
9+
use Magento\Directory\Model\CurrencyFactory;
10+
use Magento\Framework\Api\AttributeValueFactory;
11+
use Magento\Framework\Api\ExtensionAttributesFactory;
12+
use Magento\Framework\App\Cache\Type\Config;
13+
use Magento\Framework\App\Cache\TypeListInterface;
14+
use Magento\Framework\App\Config\ScopeConfigInterface;
15+
use Magento\Framework\App\ObjectManager;
16+
use Magento\Framework\Data\Collection\AbstractDb;
17+
use Magento\Framework\MessageQueue\PoisonPill\PoisonPillPutInterface;
18+
use Magento\Framework\Model\Context;
19+
use Magento\Framework\Model\ResourceModel\AbstractResource;
20+
use Magento\Framework\Registry;
21+
use Magento\Store\Model\ResourceModel\Store\CollectionFactory;
22+
823
/**
924
* Core Website model
1025
*
@@ -28,9 +43,9 @@ class Website extends \Magento\Framework\Model\AbstractExtensibleModel implement
2843
\Magento\Framework\App\ScopeInterface,
2944
\Magento\Store\Api\Data\WebsiteInterface
3045
{
31-
const ENTITY = 'store_website';
46+
public const ENTITY = 'store_website';
3247

33-
const CACHE_TAG = 'website';
48+
public const CACHE_TAG = 'website';
3449

3550
/**
3651
* @var bool
@@ -160,7 +175,7 @@ class Website extends \Magento\Framework\Model\AbstractExtensibleModel implement
160175
protected $_currencyFactory;
161176

162177
/**
163-
* @var \Magento\Framework\MessageQueue\PoisonPill\PoisonPillPutInterface
178+
* @var PoisonPillPutInterface
164179
*/
165180
private $pillPut;
166181

@@ -170,21 +185,27 @@ class Website extends \Magento\Framework\Model\AbstractExtensibleModel implement
170185
private $_coreConfig;
171186

172187
/**
173-
* @param \Magento\Framework\Model\Context $context
174-
* @param \Magento\Framework\Registry $registry
175-
* @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
176-
* @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory
177-
* @param \Magento\Config\Model\ResourceModel\Config\Data $configDataResource
178-
* @param \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig
179-
* @param \Magento\Store\Model\ResourceModel\Store\CollectionFactory $storeListFactory
180-
* @param \Magento\Store\Model\GroupFactory $storeGroupFactory
181-
* @param \Magento\Store\Model\WebsiteFactory $websiteFactory
182-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
183-
* @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
184-
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
185-
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
188+
* @var TypeListInterface
189+
*/
190+
private TypeListInterface $typeList;
191+
192+
/**
193+
* @param Context $context
194+
* @param Registry $registry
195+
* @param ExtensionAttributesFactory $extensionFactory
196+
* @param AttributeValueFactory $customAttributeFactory
197+
* @param Data $configDataResource
198+
* @param ScopeConfigInterface $coreConfig
199+
* @param CollectionFactory $storeListFactory
200+
* @param GroupFactory $storeGroupFactory
201+
* @param WebsiteFactory $websiteFactory
202+
* @param StoreManagerInterface $storeManager
203+
* @param CurrencyFactory $currencyFactory
204+
* @param AbstractResource|null $resource
205+
* @param AbstractDb|null $resourceCollection
186206
* @param array $data
187-
* @param \Magento\Framework\MessageQueue\PoisonPill\PoisonPillPutInterface|null $pillPut
207+
* @param PoisonPillPutInterface|null $pillPut
208+
* @param TypeListInterface|null $typeList
188209
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
189210
*/
190211
public function __construct(
@@ -202,7 +223,8 @@ public function __construct(
202223
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
203224
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
204225
array $data = [],
205-
\Magento\Framework\MessageQueue\PoisonPill\PoisonPillPutInterface $pillPut = null
226+
PoisonPillPutInterface $pillPut = null,
227+
TypeListInterface $typeList = null
206228
) {
207229
parent::__construct(
208230
$context,
@@ -220,8 +242,8 @@ public function __construct(
220242
$this->_websiteFactory = $websiteFactory;
221243
$this->_storeManager = $storeManager;
222244
$this->_currencyFactory = $currencyFactory;
223-
$this->pillPut = $pillPut ?: \Magento\Framework\App\ObjectManager::getInstance()
224-
->get(\Magento\Framework\MessageQueue\PoisonPill\PoisonPillPutInterface::class);
245+
$this->pillPut = $pillPut ?: ObjectManager::getInstance()->get(PoisonPillPutInterface::class);
246+
$this->typeList = $typeList ?: ObjectManager::getInstance()->get(TypeListInterface::class);
225247
}
226248

227249
/**
@@ -584,6 +606,13 @@ public function beforeDelete()
584606
public function afterDelete()
585607
{
586608
$this->_storeManager->reinitStores();
609+
$types = [
610+
'full_page',
611+
Config::TYPE_IDENTIFIER
612+
];
613+
foreach ($types as $type) {
614+
$this->typeList->cleanType($type);
615+
}
587616
parent::afterDelete();
588617
return $this;
589618
}
@@ -598,6 +627,8 @@ public function afterSave()
598627
{
599628
if ($this->isObjectNew()) {
600629
$this->_storeManager->reinitStores();
630+
} else {
631+
$this->typeList->invalidate(['full_page', Config::TYPE_IDENTIFIER]);
601632
}
602633
$this->pillPut->put();
603634
return parent::afterSave();
@@ -687,6 +718,17 @@ public function getIdentities()
687718
return [self::CACHE_TAG];
688719
}
689720

721+
/**
722+
* @inheritDoc
723+
*/
724+
public function getCacheTags()
725+
{
726+
$identities = $this->getIdentities();
727+
$parentTags = parent::getCacheTags();
728+
729+
return array_unique(array_merge($identities, $parentTags));
730+
}
731+
690732
/**
691733
* @inheritdoc
692734
* @since 100.1.0
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Store\Test\Unit\Model;
9+
10+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
11+
use Magento\Store\Model\Group;
12+
use PHPUnit\Framework\TestCase;
13+
14+
class GroupTest extends TestCase
15+
{
16+
/**
17+
* @var Group
18+
*/
19+
protected $model;
20+
21+
/**
22+
* @var ObjectManager
23+
*/
24+
protected $objectManagerHelper;
25+
26+
protected function setUp(): void
27+
{
28+
$this->objectManagerHelper = new ObjectManager($this);
29+
30+
$this->model = $this->objectManagerHelper->getObject(
31+
Group::class
32+
);
33+
}
34+
35+
public function testGetCacheTags()
36+
{
37+
$this->assertEquals([Group::CACHE_TAG], $this->model->getCacheTags());
38+
}
39+
}

app/code/Magento/Store/Test/Unit/Model/StoreManagerTest.php

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

88
namespace Magento\Store\Test\Unit\Model;
99

10+
use Magento\Framework\App\Config;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
use Magento\Framework\Cache\FrontendInterface;
1013
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1114
use Magento\Store\Api\Data\StoreInterface;
15+
use Magento\Store\Api\GroupRepositoryInterface;
1216
use Magento\Store\Api\StoreRepositoryInterface;
1317
use Magento\Store\Api\StoreResolverInterface;
18+
use Magento\Store\Api\WebsiteRepositoryInterface;
19+
use Magento\Store\Model\Group;
20+
use Magento\Store\Model\Store;
1421
use Magento\Store\Model\StoreManager;
22+
use Magento\Store\Model\StoreResolver;
23+
use Magento\Store\Model\Website;
1524
use PHPUnit\Framework\MockObject\MockObject;
1625
use PHPUnit\Framework\TestCase;
1726

27+
/**
28+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
29+
*/
1830
class StoreManagerTest extends TestCase
1931
{
2032
/**
@@ -32,6 +44,26 @@ class StoreManagerTest extends TestCase
3244
*/
3345
protected $storeResolverMock;
3446

47+
/**
48+
* @var FrontendInterface|MockObject
49+
*/
50+
private $cache;
51+
52+
/**
53+
* @var GroupRepositoryInterface
54+
*/
55+
private $groupRepository;
56+
57+
/**
58+
* @var WebsiteRepositoryInterface
59+
*/
60+
private $websiteRepository;
61+
62+
/**
63+
* @var ScopeConfigInterface
64+
*/
65+
private $scopeConfig;
66+
3567
protected function setUp(): void
3668
{
3769
$objectManager = new ObjectManager($this);
@@ -43,11 +75,27 @@ protected function setUp(): void
4375
->disableOriginalConstructor()
4476
->setMethods([])
4577
->getMockForAbstractClass();
78+
$this->cache = $this->getMockBuilder(FrontendInterface::class)
79+
->getMockForAbstractClass();
80+
$this->scopeConfig = $this->getMockBuilder(Config::class)
81+
->disableOriginalConstructor()
82+
->getMock();
83+
$this->websiteRepository = $this->getMockBuilder(WebsiteRepositoryInterface::class)
84+
->disableOriginalConstructor()
85+
->getMockForAbstractClass();
86+
$this->groupRepository = $this->getMockBuilder(GroupRepositoryInterface::class)
87+
->disableOriginalConstructor()
88+
->getMockForAbstractClass();
89+
4690
$this->model = $objectManager->getObject(
4791
StoreManager::class,
4892
[
4993
'storeRepository' => $this->storeRepositoryMock,
50-
'storeResolver' => $this->storeResolverMock
94+
'storeResolver' => $this->storeResolverMock,
95+
'cache' => $this->cache,
96+
'scopeConfig' => $this->scopeConfig,
97+
'websiteRepository' => $this->websiteRepository,
98+
'groupRepository' => $this->groupRepository
5199
]
52100
);
53101
}
@@ -95,6 +143,20 @@ public function testGetStoreObjectStoreParameter()
95143
$this->assertEquals($storeMock, $actualStore);
96144
}
97145

146+
public function testReinitStores()
147+
{
148+
$this->cache->expects($this->once())->method('clean')->with(
149+
\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG,
150+
[StoreResolver::CACHE_TAG, Store::CACHE_TAG, Website::CACHE_TAG, Group::CACHE_TAG]
151+
);
152+
$this->scopeConfig->expects($this->once())->method('clean');
153+
$this->storeRepositoryMock->expects($this->once())->method('clean');
154+
$this->websiteRepository->expects($this->once())->method('clean');
155+
$this->groupRepository->expects($this->once())->method('clean');
156+
157+
$this->model->reinitStores();
158+
}
159+
98160
/**
99161
* @dataProvider getStoresDataProvider
100162
*/

0 commit comments

Comments
 (0)