Skip to content

Commit fdf66c6

Browse files
authored
Merge pull request #4454 from magento-borg/borg-pr-2.2.10-develop
[borg] bug fixes
2 parents 2a1e51f + 2079d71 commit fdf66c6

File tree

7 files changed

+63
-19
lines changed

7 files changed

+63
-19
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ public function getStoreValuesForForm($empty = false, $all = false)
152152
}
153153
}
154154
}
155+
array_walk(
156+
$options,
157+
function (&$item) {
158+
$item['__disableTmpl'] = true;
159+
}
160+
);
155161
return $options;
156162
}
157163

app/code/Magento/Store/Test/Unit/Model/System/StoreTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,15 @@ public function getStoreValuesForFormDataProvider()
262262
'storeGroupId' => $groupId,
263263
'groupWebsiteId' => $websiteId,
264264
'expectedResult' => [
265-
['label' => '', 'value' => ''],
266-
['label' => __('All Store Views'), 'value' => 0],
267-
['label' => $websiteName, 'value' => []],
265+
['label' => '', 'value' => '','__disableTmpl' => true],
266+
['label' => __('All Store Views'), 'value' => 0,'__disableTmpl' => true],
267+
['label' => $websiteName, 'value' => [],'__disableTmpl' => true],
268268
[
269269
'label' => str_repeat($nonEscapableNbspChar, 4) . $groupName,
270270
'value' => [
271271
['label' => str_repeat($nonEscapableNbspChar, 4) . $storeName, 'value' => $storeId]
272-
]
272+
],
273+
'__disableTmpl' => true
273274
],
274275
]
275276
],

app/code/Magento/Store/Ui/Component/Listing/Column/Store/Options.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,26 @@ public function toOptionArray()
6868
return $this->options;
6969
}
7070

71+
/**
72+
* Sanitize website/store option name
73+
*
74+
* @param string $name
75+
*
76+
* @return string
77+
*/
78+
protected function sanitizeName($name)
79+
{
80+
$matches = [];
81+
preg_match('/\$[:]*{(.)*}/', $name, $matches);
82+
if (count($matches) > 0) {
83+
$name = $this->escaper->escapeHtml($this->escaper->escapeJs($name));
84+
} else {
85+
$name = $this->escaper->escapeHtml($name);
86+
}
87+
88+
return $name;
89+
}
90+
7191
/**
7292
* Generate current options
7393
*
@@ -88,20 +108,20 @@ protected function generateCurrentOptions()
88108
/** @var \Magento\Store\Model\Store $store */
89109
foreach ($storeCollection as $store) {
90110
if ($store->getGroupId() == $group->getId()) {
91-
$name = $this->escaper->escapeHtml($store->getName());
111+
$name = $this->sanitizeName($store->getName());
92112
$stores[$name]['label'] = str_repeat(' ', 8) . $name;
93113
$stores[$name]['value'] = $store->getId();
94114
}
95115
}
96116
if (!empty($stores)) {
97-
$name = $this->escaper->escapeHtml($group->getName());
117+
$name = $this->sanitizeName($group->getName());
98118
$groups[$name]['label'] = str_repeat(' ', 4) . $name;
99119
$groups[$name]['value'] = array_values($stores);
100120
}
101121
}
102122
}
103123
if (!empty($groups)) {
104-
$name = $this->escaper->escapeHtml($website->getName());
124+
$name = $this->sanitizeName($website->getName());
105125
$this->currentOptions[$name]['label'] = $name;
106126
$this->currentOptions[$name]['value'] = array_values($groups);
107127
}

app/code/Magento/Ui/view/base/web/js/grid/editing/record.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ define([
134134

135135
field = utils.extend({}, fields.base, field);
136136

137+
field.__disableTmpl = {
138+
label: true,
139+
options: true
140+
};
141+
137142
return utils.template(field, {
138143
record: this,
139144
column: column

app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/optgroup.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,14 @@ define([
222222
ko.utils.setTextContent(option, allBindings.get('optionsCaption'));
223223
ko.selectExtensions.writeValue(option, undefined);
224224
} else if (typeof arrayEntry[optionsValue] === 'undefined') { // empty value === optgroup
225-
option = utils.template(optgroupTmpl, {
226-
label: arrayEntry[optionsText],
227-
title: arrayEntry[optionsText + 'title']
228-
});
225+
if (arrayEntry.__disableTmpl) {
226+
option = '<optgroup label="' + arrayEntry[optionsText] + '"></optgroup>';
227+
} else {
228+
option = utils.template(optgroupTmpl, {
229+
label: arrayEntry[optionsText],
230+
title: arrayEntry[optionsText + 'title']
231+
});
232+
}
229233
option = ko.utils.parseHtmlFragment(option)[0];
230234

231235
} else {
@@ -307,6 +311,10 @@ define([
307311
obj.disabled = disabled;
308312
}
309313

314+
if (option.hasOwnProperty('__disableTmpl')) {
315+
obj.__disableTmpl = option.__disableTmpl;
316+
}
317+
310318
label = label.replace(nbspRe, '').trim();
311319

312320
if (Array.isArray(value)) {

dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Edit/FormTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,32 +234,35 @@ public static function getEntityStoresDataProvider()
234234
null,
235235
['entity_id' => 3, 'store_ids' => [1]],
236236
[
237-
['label' => 'Main Website', 'value' => []],
237+
['label' => 'Main Website', 'value' => [], '__disableTmpl' => true],
238238
[
239239
'label' => '    Main Website Store',
240-
'value' => [['label' => '    Default Store View', 'value' => 1]]
240+
'value' => [['label' => '    Default Store View', 'value' => 1]],
241+
'__disableTmpl' => true
241242
]
242243
],
243244
],
244245
[
245246
['entity_id' => 2, 'name' => 'product2', 'url_key' => 'product2', 'store_ids' => [1]],
246247
null,
247248
[
248-
['label' => 'Main Website', 'value' => []],
249+
['label' => 'Main Website', 'value' => [], '__disableTmpl' => true],
249250
[
250251
'label' => '    Main Website Store',
251-
'value' => [['label' => '    Default Store View', 'value' => 1]]
252+
'value' => [['label' => '    Default Store View', 'value' => 1]],
253+
'__disableTmpl' => true
252254
]
253255
]
254256
],
255257
[
256258
['entity_id' => 2, 'name' => 'product2', 'url_key' => 'product2', 'store_ids' => [1]],
257259
['entity_id' => 3, 'name' => 'product3', 'url_key' => 'product3', 'store_ids' => [1]],
258260
[
259-
['label' => 'Main Website', 'value' => []],
261+
['label' => 'Main Website', 'value' => [], '__disableTmpl' => true],
260262
[
261263
'label' => '    Main Website Store',
262-
'value' => [['label' => '    Default Store View', 'value' => 1]]
264+
'value' => [['label' => '    Default Store View', 'value' => 1]],
265+
'__disableTmpl' => true
263266
]
264267
]
265268
]

dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/Edit/FormTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ public function testGetEntityStores()
7878
$form = $this->_getFormInstance($args);
7979

8080
$expectedStores = [
81-
['label' => 'Main Website', 'value' => []],
81+
['label' => 'Main Website', 'value' => [], '__disableTmpl' => true],
8282
[
8383
'label' => '    Main Website Store',
84-
'value' => [['label' => '    Default Store View', 'value' => 1]]
84+
'value' => [['label' => '    Default Store View', 'value' => 1]],
85+
'__disableTmpl' => true
8586
],
8687
];
8788
$this->assertEquals($expectedStores, $form->getElement('store_id')->getValues());

0 commit comments

Comments
 (0)