Skip to content

Commit b1026ae

Browse files
[Magento Community Engineering] Community Contributions - 2.3-develop
- merged latest code from mainline branch
2 parents 13964ee + 484cc98 commit b1026ae

File tree

9 files changed

+112
-38
lines changed

9 files changed

+112
-38
lines changed

app/code/Magento/Email/Test/Mftf/ActionGroup/EmailTemplateActionGroup.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
<description>Clicks on Delete Template. Accepts the Popup. Validates that the Email Template is NOT present in the Email Templates Grid.</description>
6262
</annotations>
6363
<click selector="{{AdminEmailTemplateEditSection.deleteTemplateButton}}" after="checkTemplateName" stepKey="deleteTemplate"/>
64-
<acceptPopup after="deleteTemplate" stepKey="acceptPopup"/>
64+
<waitForElementVisible selector="{{AdminEmailTemplateEditSection.acceptPopupButton}}" after="deleteTemplate" stepKey="waitForConfirmButton"/>
65+
<click selector="{{AdminEmailTemplateEditSection.acceptPopupButton}}" after="waitForConfirmButton" stepKey="acceptPopup"/>
6566
<waitForElementVisible selector="{{AdminMessagesSection.successMessage}}" after="acceptPopup" stepKey="waitForSuccessMessage"/>
6667
<see selector="{{AdminMessagesSection.successMessage}}" userInput="You deleted the email template." after="waitForSuccessMessage" stepKey="seeSuccessfulMessage"/>
6768
</actionGroup>

app/code/Magento/Email/Test/Mftf/Section/AdminEmailTemplateEditSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
<element name="loadTemplateButton" type="button" selector="#load" timeout="30"/>
1717
<element name="deleteTemplateButton" type="button" selector="#delete"/>
1818
<element name="previewTemplateButton" type="button" selector="#preview" timeout="30"/>
19+
<element name="acceptPopupButton" type="button" selector=".action-accept" />
1920
</section>
2021
</sections>

app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ require([
6161
"jquery",
6262
"wysiwygAdapter",
6363
"Magento_Ui/js/modal/alert",
64+
'Magento_Ui/js/modal/confirm',
6465
"mage/mage",
6566
"Magento_Email/js/variables",
6667
"prototype"
67-
], function(jQuery, tinyMCE, alert){
68+
], function(jQuery, tinyMCE, alert, confirm){
6869

6970
//<![CDATA[
7071
jQuery('#email_template_edit_form').mage('form').mage('validation');
@@ -113,18 +114,22 @@ require([
113114
},
114115

115116
stripTags: function () {
116-
if(!window.confirm("<?= $block->escapeJs($block->escapeHtml(__('Are you sure you want to strip tags?'))) ?>")) {
117-
return false;
118-
}
119-
this.unconvertedText = $('template_text').value;
120-
$('convert_button').hide();
121-
$('template_text').value = $('template_text').value.stripScripts().replace(
122-
new RegExp('<style[^>]*>[\\S\\s]*?</style>', 'img'), ''
123-
).stripTags().strip();
124-
$('convert_button_back').show();
125-
$('field_template_styles').hide();
126-
this.typeChange = true;
127-
return false;
117+
confirm({
118+
content: "<?= $block->escapeJs($block->escapeHtml(__('Are you sure you want to strip tags?'))) ?>",
119+
actions: {
120+
confirm: function () {
121+
this.unconvertedText = $('template_text').value;
122+
$('convert_button').hide();
123+
$('template_text').value = $('template_text').value.stripScripts().replace(
124+
new RegExp('<style[^>]*>[\\S\\s]*?</style>', 'img'), ''
125+
).stripTags().strip();
126+
$('convert_button_back').show();
127+
$('field_template_styles').hide();
128+
this.typeChange = true;
129+
return false;
130+
}
131+
}
132+
});
128133
},
129134
unStripTags: function () {
130135
$('convert_button').show();
@@ -164,9 +169,14 @@ require([
164169
},
165170

166171
deleteTemplate: function() {
167-
if(window.confirm("<?= $block->escapeJs($block->escapeHtml(__('Are you sure you want to delete this template?'))) ?>")) {
168-
window.location.href = '<?= $block->escapeJs($block->escapeUrl($block->getDeleteUrl())) ?>';
169-
}
172+
confirm({
173+
content: "<?= $block->escapeJs($block->escapeHtml(__('Are you sure you want to delete this template?'))) ?>",
174+
actions: {
175+
confirm: function () {
176+
window.location.href = '<?= $block->escapeJs($block->escapeUrl($block->getDeleteUrl())) ?>';
177+
}
178+
}
179+
});
170180
},
171181

172182
load: function() {

app/code/Magento/Paypal/Model/AbstractConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public function isMethodActive($method)
293293
case Config::METHOD_WPS_BML:
294294
case Config::METHOD_WPP_BML:
295295
$disabledFunding = $this->_scopeConfig->getValue(
296-
'payment/paypal_express/disable_funding_options',
296+
'paypal/style/disable_funding_options',
297297
ScopeInterface::SCOPE_STORE,
298298
$this->_storeId
299299
);

app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public function testIsMethodActiveBml($disableFundingOptions, $expectedFlag, $ex
306306
{
307307
$this->scopeConfigMock->method('getValue')
308308
->with(
309-
self::equalTo('payment/paypal_express/disable_funding_options'),
309+
self::equalTo('paypal/style/disable_funding_options'),
310310
self::equalTo('store')
311311
)
312312
->willReturn($disableFundingOptions);

app/code/Magento/Paypal/Test/Unit/Model/ConfigTest.php

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Store\Model\ScopeInterface;
1010
use Magento\Framework\App\Config\ScopeConfigInterface;
1111

12+
/**
13+
* Class ConfigTest
14+
*/
1215
class ConfigTest extends \PHPUnit\Framework\TestCase
1316
{
1417
/**
@@ -122,7 +125,7 @@ public function testIsMethodAvailableForIsMethodActive($methodName, $expected)
122125
$valueMap = [
123126
['paypal/general/merchant_country', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, 'US'],
124127
['paypal/general/merchant_country', ScopeInterface::SCOPE_STORE, null, 'US'],
125-
['payment/paypal_express/disable_funding_options', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, []],
128+
['paypal/style/disable_funding_options', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, []],
126129
];
127130
$this->scopeConfig
128131
->method('getValue')
@@ -362,11 +365,15 @@ public function testGetBmlDisplay($section, $expectedValue, $expectedFlag, $expe
362365
->will($this->returnValue($expectedFlag));
363366
$this->scopeConfig->expects($this->any())
364367
->method('getValue')
365-
->will($this->returnValueMap([
366-
['payment/' . Config::METHOD_WPP_BML . '/' . $section . '_display', 'store', 1, $expectedValue],
367-
['payment/' . Config::METHOD_WPP_BML . '/active', 'store', 1, $expectedValue],
368-
['payment/' . Config::METHOD_WPP_PE_BML . '/active', 'store', 1, $expectedValue],
369-
]));
368+
->will(
369+
$this->returnValueMap(
370+
[
371+
['payment/' . Config::METHOD_WPP_BML . '/' . $section . '_display', 'store', 1, $expectedValue],
372+
['payment/' . Config::METHOD_WPP_BML . '/active', 'store', 1, $expectedValue],
373+
['payment/' . Config::METHOD_WPP_PE_BML . '/active', 'store', 1, $expectedValue],
374+
]
375+
)
376+
);
370377
$this->assertEquals($expected, $this->model->getBmlDisplay($section));
371378
}
372379

@@ -407,11 +414,13 @@ public function testGetExpressCheckoutShortcutImageUrl(
407414

408415
$this->scopeConfig->expects($this->any())
409416
->method('getValue')
410-
->willReturnMap([
411-
['paypal/wpp/button_flavor', ScopeInterface::SCOPE_STORE, 123, $areButtonDynamic],
412-
['paypal/wpp/sandbox_flag', ScopeInterface::SCOPE_STORE, 123, $sandboxFlag],
413-
['paypal/wpp/button_type', ScopeInterface::SCOPE_STORE, 123, $buttonType],
414-
]);
417+
->willReturnMap(
418+
[
419+
['paypal/wpp/button_flavor', ScopeInterface::SCOPE_STORE, 123, $areButtonDynamic],
420+
['paypal/wpp/sandbox_flag', ScopeInterface::SCOPE_STORE, 123, $sandboxFlag],
421+
['paypal/wpp/button_type', ScopeInterface::SCOPE_STORE, 123, $buttonType],
422+
]
423+
);
415424

416425
$this->assertEquals(
417426
$result,
@@ -475,10 +484,12 @@ public function testGetPaymentMarkImageUrl(
475484

476485
$this->scopeConfig->expects($this->any())
477486
->method('getValue')
478-
->willReturnMap([
479-
['paypal/wpp/button_flavor', ScopeInterface::SCOPE_STORE, 123, $areButtonDynamic],
480-
['paypal/wpp/sandbox_flag', ScopeInterface::SCOPE_STORE, 123, $sandboxFlag],
481-
]);
487+
->willReturnMap(
488+
[
489+
['paypal/wpp/button_flavor', ScopeInterface::SCOPE_STORE, 123, $areButtonDynamic],
490+
['paypal/wpp/sandbox_flag', ScopeInterface::SCOPE_STORE, 123, $sandboxFlag],
491+
]
492+
);
482493

483494
$this->assertEquals(
484495
$result,

app/code/Magento/Widget/Block/Adminhtml/Widget/Instance/Edit/Tab/Main.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
6+
declare(strict_types=1);
77
/**
88
* Widget Instance Main tab block
99
*
@@ -12,6 +12,8 @@
1212
namespace Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Tab;
1313

1414
/**
15+
* Edit Main Tab
16+
*
1517
* @api
1618
* @since 100.0.2
1719
*/
@@ -198,7 +200,7 @@ protected function _prepareForm()
198200
'name' => 'sort_order',
199201
'label' => __('Sort Order'),
200202
'title' => __('Sort Order'),
201-
'class' => '',
203+
'class' => 'validate-number',
202204
'required' => false,
203205
'note' => __('Sort Order of widget instances in the same container')
204206
]

lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,36 @@ public function date($date = null, $locale = null, $useTimezone = true, $include
196196
public function scopeDate($scope = null, $date = null, $includeTime = false)
197197
{
198198
$timezone = $this->_scopeConfig->getValue($this->getDefaultTimezonePath(), $this->_scopeType, $scope);
199-
$date = new \DateTime(is_numeric($date) ? '@' . $date : $date);
200-
$date->setTimezone(new \DateTimeZone($timezone));
199+
switch (true) {
200+
case (empty($date)):
201+
$date = new \DateTime('now', new \DateTimeZone($timezone));
202+
break;
203+
case ($date instanceof \DateTime):
204+
$date = $date->setTimezone(new \DateTimeZone($timezone));
205+
break;
206+
case ($date instanceof \DateTimeImmutable):
207+
$date = new \DateTime($date->format('Y-m-d H:i:s'), $date->getTimezone());
208+
break;
209+
case (!is_numeric($date)):
210+
$timeType = $includeTime ? \IntlDateFormatter::SHORT : \IntlDateFormatter::NONE;
211+
$formatter = new \IntlDateFormatter(
212+
$this->_localeResolver->getLocale(),
213+
\IntlDateFormatter::SHORT,
214+
$timeType,
215+
new \DateTimeZone($timezone)
216+
);
217+
$date = $formatter->parse($date) ?: (new \DateTime($date))->getTimestamp();
218+
$date = (new \DateTime(null, new \DateTimeZone($timezone)))->setTimestamp($date);
219+
break;
220+
default:
221+
$date = new \DateTime(is_numeric($date) ? '@' . $date : $date);
222+
$date->setTimezone(new \DateTimeZone($timezone));
223+
}
224+
201225
if (!$includeTime) {
202226
$date->setTime(0, 0, 0);
203227
}
228+
204229
return $date;
205230
}
206231

lib/internal/Magento/Framework/View/Model/Layout/Merge.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Layout merge model
1919
* @SuppressWarnings(PHPMD.TooManyFields)
2020
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
21+
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
2122
*/
2223
class Merge implements \Magento\Framework\View\Layout\ProcessorInterface
2324
{
@@ -462,6 +463,8 @@ public function load($handles = [])
462463
return $this;
463464
}
464465

466+
$this->extractHandlers();
467+
465468
foreach ($this->getHandles() as $handle) {
466469
$this->_merge($handle);
467470
}
@@ -951,4 +954,25 @@ public function getCacheId()
951954
// phpcs:ignore Magento2.Security.InsecureFunction
952955
return $this->generateCacheId(md5(implode('|', array_merge($this->getHandles(), $layoutCacheKeys))));
953956
}
957+
958+
/**
959+
* Walk all updates and extract handles before the merge step.
960+
*/
961+
private function extractHandlers(): void
962+
{
963+
foreach ($this->updates as $update) {
964+
$updateXml = null;
965+
966+
try {
967+
$updateXml = $this->_loadXmlString($update);
968+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
969+
} catch (\Exception $exception) {
970+
// ignore invalid
971+
}
972+
973+
if ($updateXml && strtolower($updateXml->getName()) == 'update' && isset($updateXml['handle'])) {
974+
$this->addHandle((string)$updateXml['handle']);
975+
}
976+
}
977+
}
954978
}

0 commit comments

Comments
 (0)