Skip to content

Commit e87d4e6

Browse files
committed
Merge branch 'project_pepe' into mftf
2 parents 9e82e91 + 61d3ffa commit e87d4e6

File tree

21 files changed

+110
-101
lines changed

21 files changed

+110
-101
lines changed

app/code/Magento/Analytics/Test/Mftf/Test/AdminConfigurationTimeToSendDataTest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
<amOnPage url="{{AdminConfigGeneralAnalyticsPage.url}}" stepKey="amOnAdminConfig"/>
2626
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingService}}" userInput="Enable" stepKey="selectAdvancedReportingServiceEnabled"/>
2727
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingIndustry}}" userInput="Apps and Games" stepKey="selectAdvancedReportingIndustry"/>
28-
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingHour}}" userInput="11" stepKey="selectAdvancedReportingHour"/>
29-
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingMinute}}" userInput="11" stepKey="selectAdvancedReportingMinute"/>
30-
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingSeconds}}" userInput="00" stepKey="selectAdvancedReportingSeconds"/>
28+
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingHour}}" userInput="23" stepKey="selectAdvancedReportingHour"/>
29+
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingMinute}}" userInput="59" stepKey="selectAdvancedReportingMinute"/>
30+
<selectOption selector="{{AdminConfigAdvancedReportingSection.advancedReportingSeconds}}" userInput="59" stepKey="selectAdvancedReportingSeconds"/>
3131
<click selector="{{AdminMainActionsSection.save}}" stepKey="clickSaveConfigButton"/>
3232
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the configuration." stepKey="seeSuccess"/>
3333
</test>

app/code/Magento/Checkout/etc/frontend/sections.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
1010
<action name="checkout/cart/add">
1111
<section name="cart"/>
12+
<section name="directory-data"/>
1213
</action>
1314
<action name="checkout/cart/delete">
1415
<section name="cart"/>

app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ define([
103103
});
104104

105105
if (
106-
cartData().website_id !== window.checkout.websiteId &&
107-
cartData().website_id !== undefined
106+
cartData().website_id !== window.checkout.websiteId && cartData().website_id !== undefined ||
107+
cartData().storeId !== window.checkout.storeId && cartData().storeId !== undefined
108108
) {
109109
customerData.reload(['cart'], false);
110110
}
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+
namespace Magento\Customer\Block;
7+
8+
use Magento\Customer\CustomerData\SectionPool;
9+
use Magento\Framework\View\Element\Block\ArgumentInterface;
10+
11+
/**
12+
* ViewModel to get sections names array.
13+
*/
14+
class SectionNamesProvider implements ArgumentInterface
15+
{
16+
/**
17+
* @var SectionPool
18+
*/
19+
private $sectionPool;
20+
21+
/**
22+
* @param SectionPool $sectionPool
23+
*/
24+
public function __construct(
25+
SectionPool $sectionPool
26+
) {
27+
$this->sectionPool = $sectionPool;
28+
}
29+
30+
/**
31+
* Return array of section names based on config.
32+
*
33+
* @return array
34+
*/
35+
public function getSectionNames()
36+
{
37+
return $this->sectionPool->getSectionNames();
38+
}
39+
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ public function getSectionsData(array $sectionNames = null, $forceNewTimestamp =
6262
return $sectionsData;
6363
}
6464

65+
/**
66+
* Return array of section names.
67+
*
68+
* @return array
69+
*/
70+
public function getSectionNames()
71+
{
72+
return array_keys($this->sectionSourceMap);
73+
}
74+
6575
/**
6676
* Get section sources by section names
6777
*

app/code/Magento/Customer/etc/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@
157157
<argument name="sectionConfig" xsi:type="object">SectionInvalidationConfigData</argument>
158158
</arguments>
159159
</type>
160+
<type name="Magento\Customer\Block\SectionNamesProvider">
161+
<arguments>
162+
<argument name="sectionConfig" xsi:type="object">SectionInvalidationConfigData</argument>
163+
</arguments>
164+
</type>
160165
<preference for="Magento\Customer\CustomerData\JsLayoutDataProviderPoolInterface"
161166
type="Magento\Customer\CustomerData\JsLayoutDataProviderPool"/>
162167
<type name="Magento\Framework\Webapi\ServiceTypeToEntityTypeMap">

app/code/Magento/Customer/view/frontend/layout/default.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@
4141
</arguments>
4242
</block>
4343
<block name="customer.section.config" class="Magento\Customer\Block\SectionConfig"
44-
template="Magento_Customer::js/section-config.phtml"/>
45-
<block name="customer.customer.data"
46-
class="Magento\Customer\Block\CustomerData"
44+
template="Magento_Customer::js/section-config.phtml">
45+
<arguments>
46+
<argument name="sectionNamesProvider" xsi:type="object">Magento\Customer\Block\SectionNamesProvider</argument>
47+
</arguments>
48+
</block>
49+
<block name="customer.customer.data" class="Magento\Customer\Block\CustomerData"
4750
template="Magento_Customer::js/customer-data.phtml"/>
4851
<block name="customer.data.invalidation.rules" class="Magento\Customer\Block\CustomerScopeData"
4952
template="Magento_Customer::js/customer-data/invalidation-rules.phtml"/>

app/code/Magento/Customer/view/frontend/templates/js/section-config.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"baseUrls": <?= /* @noEscape */ $this->helper(\Magento\Framework\Json\Helper\Data::class)->jsonEncode(array_unique([
1616
$block->getUrl(null, ['_secure' => true]),
1717
$block->getUrl(null, ['_secure' => false]),
18-
])) ?>
18+
])) ?>,
19+
"sectionNames": <?= /* @noEscape */ $this->helper(\Magento\Framework\Json\Helper\Data::class)
20+
->jsonEncode($block->getData('sectionNamesProvider')->getSectionNames()) ?>
1921
}
2022
}
2123
}

app/code/Magento/Customer/view/frontend/web/js/customer-data.js

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -198,30 +198,9 @@ define([
198198
* Customer data initialization
199199
*/
200200
init: function () {
201-
var privateContentVersion = 'private_content_version',
202-
privateContent = $.cookieStorage.get(privateContentVersion),
203-
localPrivateContent = $.localStorage.get(privateContentVersion),
204-
needVersion = 'need_version',
205-
expiredSectionNames = this.getExpiredSectionNames();
206-
207-
if (privateContent &&
208-
!$.cookieStorage.isSet(privateContentVersion) &&
209-
!$.localStorage.isSet(privateContentVersion)
210-
) {
211-
$.cookieStorage.set(privateContentVersion, needVersion);
212-
$.localStorage.set(privateContentVersion, needVersion);
213-
this.reload([], false);
214-
} else if (localPrivateContent !== privateContent) {
215-
if (!$.cookieStorage.isSet(privateContentVersion)) {
216-
privateContent = needVersion;
217-
$.cookieStorage.set(privateContentVersion, privateContent);
218-
}
219-
$.localStorage.set(privateContentVersion, privateContent);
220-
_.each(dataProvider.getFromStorage(storage.keys()), function (sectionData, sectionName) {
221-
buffer.notify(sectionName, sectionData);
222-
});
223-
this.reload([], false);
224-
} else if (expiredSectionNames.length > 0) {
201+
var expiredSectionNames = this.getExpiredSectionNames();
202+
203+
if (expiredSectionNames.length > 0) {
225204
_.each(dataProvider.getFromStorage(storage.keys()), function (sectionData, sectionName) {
226205
buffer.notify(sectionName, sectionData);
227206
});
@@ -341,7 +320,9 @@ define([
341320
var sectionDataIds,
342321
sectionsNamesForInvalidation;
343322

344-
sectionsNamesForInvalidation = _.contains(sectionNames, '*') ? buffer.keys() : sectionNames;
323+
sectionsNamesForInvalidation = _.contains(sectionNames, '*') ? sectionConfig.getSectionNames() :
324+
sectionNames;
325+
345326
$(document).trigger('customer-data-invalidate', [sectionsNamesForInvalidation]);
346327
buffer.remove(sectionsNamesForInvalidation);
347328
sectionDataIds = $.cookieStorage.get('section_data_ids') || {};

app/code/Magento/Customer/view/frontend/web/js/section-config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
define(['underscore'], function (_) {
77
'use strict';
88

9-
var baseUrls, sections, clientSideSections, canonize;
9+
var baseUrls, sections, clientSideSections, sectionNames, canonize;
1010

1111
/**
1212
* @param {String} url
@@ -70,6 +70,15 @@ define(['underscore'], function (_) {
7070
return _.contains(clientSideSections, sectionName);
7171
},
7272

73+
/**
74+
* Returns array of section names.
75+
*
76+
* @returns {Array}
77+
*/
78+
getSectionNames: function () {
79+
return sectionNames;
80+
},
81+
7382
/**
7483
* @param {Object} options
7584
* @constructor
@@ -78,6 +87,7 @@ define(['underscore'], function (_) {
7887
baseUrls = options.baseUrls;
7988
sections = options.sections;
8089
clientSideSections = options.clientSideSections;
90+
sectionNames = options.sectionNames;
8191
}
8292
};
8393
});

app/code/Magento/Persistent/etc/frontend/sections.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@
1010
<action name="persistent/index/unsetCookie">
1111
<section name="persistent"/>
1212
</action>
13+
<action name="customer/account/logout">
14+
<section name="persistent"/>
15+
</action>
1316
</config>

app/code/Magento/Quote/Test/Mftf/Test/StorefrontGuestCheckoutDisabledProductTest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@
7373
<requiredEntity createDataKey="createConfigProduct"/>
7474
<requiredEntity createDataKey="createConfigChildProduct2"/>
7575
</createData>
76+
<magentoCLI command="config:set customer/online_customers/section_data_lifetime 1"
77+
stepKey="setConfigForCartLifetime"/>
78+
<magentoCLI command="cache:flush" stepKey="flushCache" />
7679
</before>
7780
<after>
7881
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
@@ -116,6 +119,7 @@
116119
</actionGroup>
117120
<closeTab stepKey="closeTab"/>
118121
<!-- Check cart -->
122+
<wait time="60" stepKey="waitForCartToBeUpdated"/>
119123
<reloadPage stepKey="reloadPage"/>
120124
<waitForPageLoad stepKey="waitForCheckoutPageReload"/>
121125
<click selector="{{StorefrontMiniCartSection.show}}" stepKey="clickMiniCart"/>
@@ -143,6 +147,7 @@
143147
</actionGroup>
144148
<closeTab stepKey="closeTab2"/>
145149
<!--Check cart-->
150+
<wait time="60" stepKey="waitForCartToBeUpdated2"/>
146151
<reloadPage stepKey="reloadPage2"/>
147152
<waitForPageLoad stepKey="waitForCheckoutPageReload2"/>
148153
<click selector="{{StorefrontMiniCartSection.show}}" stepKey="clickMiniCart2"/>

dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Block/Adminhtml/Block/Agreement/Edit/AgreementsForm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<input>select</input>
1919
</mode>
2020
<stores>
21-
<selector>[name="stores[0]"]</selector>
21+
<selector>[name="stores[]"]</selector>
2222
<input>multiselectgrouplist</input>
2323
</stores>
2424
<checkbox_text />

dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class CustomerForm extends Form
2929
*
3030
* @var string
3131
*/
32-
protected $customerAttribute = "[orig-name='%s[]']";
32+
protected $customerAttribute = "[name='%s[]']";
3333

3434
/**
3535
* Validation text message for a field.

dev/tests/functional/tests/app/Magento/Newsletter/Test/Block/Adminhtml/Queue/Edit/QueueForm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<selector>input[name='start_at']</selector>
1212
</queue_start_at>
1313
<stores>
14-
<selector>select[name="stores[0]"]</selector>
14+
<selector>select[name="stores[]"]</selector>
1515
<input>multiselectgrouplist</input>
1616
</stores>
1717
<newsletter_subject>

dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Sales/Coupons/Filter.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<input>select</input>
3030
</price_rule_type>
3131
<order_statuses>
32-
<selector>[name="order_statuses[0]"]</selector>
32+
<selector>[name="order_statuses[]"]</selector>
3333
<input>multiselect</input>
3434
</order_statuses>
3535
<rules_list>

dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Sales/TaxRule/Filter.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<input>select</input>
2424
</show_order_statuses>
2525
<order_statuses>
26-
<selector>[name="order_statuses[0]"]</selector>
26+
<selector>[name="order_statuses[]"]</selector>
2727
<input>multiselect</input>
2828
</order_statuses>
2929
<show_empty_rows>

dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Rating/Edit/RatingForm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<strategy>css selector</strategy>
1313
<fields>
1414
<stores>
15-
<selector>[name="stores[0]"]</selector>
15+
<selector>[name="stores[]"]</selector>
1616
<input>multiselectgrouplist</input>
1717
</stores>
1818
<is_active>

dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Report/Filter/Form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<input>select</input>
2727
</show_order_statuses>
2828
<order_statuses>
29-
<selector>[name="order_statuses[0]"]</selector>
29+
<selector>[name="order_statuses[]"]</selector>
3030
<input>multiselect</input>
3131
</order_statuses>
3232
<show_actual_columns>

lib/web/mage/validation.js

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,6 @@
19251925
* @protected
19261926
*/
19271927
_create: function () {
1928-
this._prepareArrayInputs();
19291928
this.validate = this.element.validate(this.options);
19301929

19311930
// ARIA (adding aria-required attribute)
@@ -1938,50 +1937,6 @@
19381937
this._listenFormValidate();
19391938
},
19401939

1941-
/**
1942-
* Validation creation.
1943-
*
1944-
* @protected
1945-
*/
1946-
_prepareArrayInputs: function () {
1947-
/* Store original names for array inputs */
1948-
var originalElements = [],
1949-
originalSubmitHandler = this.options.submitHandler;
1950-
1951-
/* For all array inputs, assign index so that validation is proper */
1952-
this.element.find('[name$="[]"]').each(function (key, input) {
1953-
var originalName, name;
1954-
1955-
input = $(input);
1956-
originalName = input.attr('name');
1957-
name = originalName.replace('[]', '[' + key + ']');
1958-
$(input).attr('name', name);
1959-
$(input).attr('orig-name', originalName);
1960-
originalElements.push({
1961-
element: $(input),
1962-
name: originalName
1963-
});
1964-
});
1965-
1966-
if (originalElements.length) {
1967-
/**
1968-
* Before submitting the actual form, remove the previously assigned indices
1969-
* @param {Object} form
1970-
*/
1971-
this.options.submitHandler = function (form) {
1972-
originalElements.forEach(function (element) {
1973-
element.element.attr('name', element.name);
1974-
element.element.removeAttr('orig-name');
1975-
});
1976-
1977-
console.error(this.submit);
1978-
1979-
/* Call the originalSubmitHandler if it's a function */
1980-
typeof originalSubmitHandler === 'function' ? originalSubmitHandler(form) : form.submit();
1981-
};
1982-
}
1983-
},
1984-
19851940
/**
19861941
* Validation listening.
19871942
*

lib/web/mage/validation/validation.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,18 @@
4949
'validate-one-checkbox-required-by-name': [
5050
function (value, element, params) {
5151
var checkedCount = 0,
52-
selector,
53-
container,
54-
origNameSelector,
55-
nameSelector;
52+
container;
5653

5754
if (element.type === 'checkbox') {
58-
/* If orig-name attribute is present, use it for validation. Else use name */
59-
origNameSelector = '[orig-name="' + element.getAttribute('orig-name') + '"]';
60-
nameSelector = '[name="' + element.name + '"]';
61-
selector = element.getAttribute('orig-name') ? origNameSelector : nameSelector;
62-
$(selector).each(function () {
63-
if ($(this).is(':checked')) {
64-
checkedCount += 1;
65-
66-
return false;
55+
$('[name="' + element.name + '"]').each(
56+
function () {
57+
if ($(this).is(':checked')) {
58+
checkedCount += 1;
59+
60+
return false;
61+
}
6762
}
68-
});
63+
);
6964
}
7065
container = '#' + params;
7166

0 commit comments

Comments
 (0)