Skip to content

Commit 5b22c3d

Browse files
MC-30786: [Escalation] Re: Magento 2.3.4 | serious issues with local storage if custom sections.xml invalidations are active
- expanding unit test variations
1 parent 3a944e1 commit 5b22c3d

File tree

4 files changed

+83
-10
lines changed

4 files changed

+83
-10
lines changed

app/code/Magento/Customer/CustomerData/SectionConfigConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function convert($source)
3535
}
3636
}
3737
if (!isset($sections[$actionName])) {
38-
$sections[$actionName] = self::INVALIDATE_ALL_SECTIONS_MARKER;
38+
$sections[$actionName][] = self::INVALIDATE_ALL_SECTIONS_MARKER;
3939
}
4040
}
4141
return [

app/code/Magento/Customer/Test/Unit/CustomerData/SectionConfigConverterTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,18 @@ public function testConvert()
7373
$this->assertEquals(
7474
[
7575
'sections' => [
76-
'customer/account/logout' => ['*'],
77-
'empty/test' => ['account'],
78-
'customer/account/editpost' => ['account'],
79-
'customer/account/createpost' => ['account', 'acc'],
76+
'sales/guest/reorder' => ['account'],
77+
'sales/order/reorder' => ['account', 'cart'],
78+
'stores/store/switch' => ['*'],
79+
'directory/currency/switch' => ['*'],
80+
'customer/account/logout' => ['account', 'cart'],
81+
'customer/account/editpost' => ['account', 'acc', 'cart'],
82+
'checkout/cart/delete' => ['*'],
83+
'customer/account/createpost' => ['*'],
84+
'catalog/product_compare/add' => ['*'],
85+
'catalog/product_compare/remove' => ['account', 'acc'],
86+
'catalog/product_compare/clear' => ['*'],
87+
'checkout/cart/add' => ['*'],
8088
],
8189
],
8290
$this->converter->convert($this->configMergerClass->getDom())

app/code/Magento/Customer/Test/Unit/CustomerData/_files/sections.xml

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,56 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
10-
<!-- xml merger merge same actions name into one node -->
11-
<action name="customer/account/logout">
10+
<!-- Actions 1-4 are specified in sections.xml file only -->
11+
<!-- 1 - Action has one Section -->
12+
<action name="sales/guest/reorder">
13+
<section name="account"/>
14+
</action>
15+
<!-- 2 - Action has two Sections -->
16+
<action name="sales/order/reorder">
17+
<section name="account"/>
1218
<section name="cart"/>
19+
</action>
20+
<!-- 3 - Action has two Sections and "*" -->
21+
<action name="stores/store/switch">
22+
<section name="account"/>
1323
<section name="*"/>
14-
<section name="acc"/>
24+
<section name="cart"/>
25+
</action>
26+
<!-- 4 - Action has "empty_section" -->
27+
<action name="directory/currency/switch"/>
28+
<!-- Actions 5-12 are specified in files sections.xml and sections2.xml for merging -->
29+
<!-- 5 - Action in both files has unique Section -->
30+
<action name="customer/account/logout">
31+
<section name="account"/>
1532
</action>
33+
<!-- 6 - Action in both files has at least one identical Section -->
1634
<action name="customer/account/editPost">
1735
<section name="account"/>
36+
<section name="acc"/>
1837
</action>
38+
<!-- 7 - Action in both files has at least one identical Section and "*" -->
39+
<action name="checkout/cart/delete">
40+
<section name="account"/>
41+
<section name="acc"/>
42+
</action>
43+
<!-- 8 - Action in both files has Section and "*" -->
1944
<action name="customer/account/createPost">
2045
<section name="account"/>
46+
</action>
47+
<!-- 9 - Action in both files has "*" and "*" -->
48+
<action name="catalog/product_compare/add">
49+
<section name="*"/>
50+
</action>
51+
<!-- 10 - Action in both files has Section and "empty_section" -->
52+
<action name="catalog/product_compare/remove">
53+
<section name="account"/>
2154
<section name="acc"/>
2255
</action>
23-
<action name="empty/test"/>
56+
<!-- 11 - Action in both files has "empty_section" and "empty_section" -->
57+
<action name="catalog/product_compare/clear"/>
58+
<!-- 12 - Action in both files has "*" and "empty_section" -->
59+
<action name="checkout/cart/add">
60+
<section name="*"/>
61+
</action>
2462
</config>

app/code/Magento/Customer/Test/Unit/CustomerData/_files/sections2.xml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,34 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
10-
<action name="empty/test">
10+
<!-- Actions 5-12 are specified in files sections.xml and sections2.xml for merging -->
11+
<!-- 5 - Action in both files has unique Section -->
12+
<action name="customer/account/logout">
13+
<section name="cart"/>
14+
</action>
15+
<!-- 6 - Action in both files has at least one identical Section -->
16+
<action name="customer/account/editPost">
17+
<section name="cart"/>
18+
<section name="account"/>
19+
</action>
20+
<!-- 7 - Action in both files has at least one identical Section and "*" -->
21+
<action name="checkout/cart/delete">
22+
<section name="cart"/>
23+
<section name="*"/>
1124
<section name="account"/>
1225
</action>
26+
<!-- 8 - Action in both files has Section and "*" -->
27+
<action name="customer/account/createPost">
28+
<section name="*"/>
29+
</action>
30+
<!-- 9 - Action in both files has "*" and "*" -->
31+
<action name="catalog/product_compare/add">
32+
<section name="*"/>
33+
</action>
34+
<!-- 10 - Action in both files has Section and "empty_section" -->
35+
<action name="catalog/product_compare/remove"/>
36+
<!-- 11 - Action in both files has "empty_section" and "empty_section" -->
37+
<action name="catalog/product_compare/clear"/>
38+
<!-- 12 - Action in both files has "*" and "empty_section" -->
39+
<action name="checkout/cart/add"/>
1340
</config>

0 commit comments

Comments
 (0)