Skip to content

Commit f9458b2

Browse files
Merge pull request #9314 from magento-cia/cia-2.4.8-beta2-develop-bugfix-10212024
Cia 2.4.8 beta2 develop bugfix 10212024
2 parents bca0482 + 626d917 commit f9458b2

File tree

17 files changed

+233
-16
lines changed

17 files changed

+233
-16
lines changed

app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* Adminhtml dashboard recent orders grid
1515
*
1616
* @api
17-
* @author Magento Core Team <[email protected]>
1817
* @SuppressWarnings(PHPMD.DepthOfInheritance)
1918
* @since 100.0.2
2019
*/
@@ -152,7 +151,7 @@ protected function _prepareColumns()
152151
'header' => __('Total'),
153152
'sortable' => false,
154153
'type' => 'currency',
155-
'currency_code' => $baseCurrencyCode,
154+
'currency_code' => $this->escapeHtml($baseCurrencyCode),
156155
'index' => 'revenue'
157156
]
158157
);

app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Weight.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function getElementHtml()
122122
$html .= '<label class="admin__addon-suffix" for="' .
123123
$this->getHtmlId() .
124124
'"><span>' .
125-
$this->directoryHelper->getWeightUnit() .
125+
$this->_escaper->escapeHtml($this->directoryHelper->getWeightUnit()) .
126126
'</span></label></div>';
127127

128128
if ($afterElementJs = $this->getAfterElementJs()) {

app/code/Magento/Config/Block/System/Config/Form/Field/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected function _getDeleteCheckbox()
5555
$html .= '<input type="hidden" name="' .
5656
parent::getName() .
5757
'[value]" value="' .
58-
$this->getValue() .
58+
$this->_escaper->escapeHtml($this->getValue()) .
5959
'" />';
6060
$html .= '</div>';
6161
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Config\Plugin\Model\Config\Backend;
10+
11+
use Magento\Config\Model\Config\Backend\Locale;
12+
use Magento\Config\Model\Config\Source\Locale\Currency\All;
13+
use Magento\Framework\Exception\LocalizedException;
14+
15+
class LocalePlugin
16+
{
17+
/**
18+
* @var All
19+
*/
20+
private $currencyList;
21+
22+
/**
23+
* @param All $currencyList
24+
*/
25+
public function __construct(
26+
All $currencyList
27+
) {
28+
$this->currencyList = $currencyList;
29+
}
30+
31+
/**
32+
* Check whether currency code value is acceptable or not
33+
*
34+
* @param Locale $subject
35+
* @return void
36+
*/
37+
public function beforeSave(Locale $subject): void
38+
{
39+
if ($subject->isValueChanged()) {
40+
$values = $subject->getValue();
41+
if (count(array_diff($values, $this->getOptions()))) {
42+
throw new LocalizedException(__('There was an error save new configuration value.'));
43+
}
44+
}
45+
}
46+
47+
/**
48+
* Get available options for weight unit
49+
*
50+
* @return array
51+
*/
52+
private function getOptions()
53+
{
54+
$options = $this->currencyList->toOptionArray();
55+
56+
return array_column($options, 'value');
57+
}
58+
}

app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/FileTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,13 @@ public function testGetElementHtml(): void
114114
$expectedHtmlId = $this->testData['html_id_prefix']
115115
. $this->testData['html_id']
116116
. $this->testData['html_id_suffix'];
117+
$escapeValue = $this->testData['value'];
117118
$this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnMap(
118119
[
119120
[$expectedHtmlId, null, $expectedHtmlId],
120121
[self::XSS_FILE_NAME_TEST, null, self::XSS_FILE_NAME_TEST],
121122
[self::INPUT_NAME_TEST, null, self::INPUT_NAME_TEST],
123+
[$escapeValue, null, $escapeValue],
122124
]
123125
);
124126

app/code/Magento/Config/etc/adminhtml/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@
99
<preference for="Magento\Config\Model\Config\Backend\File\RequestData\RequestDataInterface" type="Magento\Config\Model\Config\Backend\File\RequestData" />
1010
<type name="Magento\Config\Model\Config\Structure\Element\Iterator\Tab" shared="false" />
1111
<type name="Magento\Config\Model\Config\Structure\Element\Iterator\Section" shared="false" />
12+
<type name="Magento\Config\Model\Config\Backend\Locale">
13+
<plugin name="installed_currency_configuration_validation"
14+
type="Magento\Config\Plugin\Model\Config\Backend\LocalePlugin" sortOrder="10" />
15+
</type>
1216
</config>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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\Directory\Model\Config\Backend;
9+
10+
use Magento\Directory\Model\Config\Source\WeightUnit as Source;
11+
use Magento\Framework\App\Cache\TypeListInterface;
12+
use Magento\Framework\App\Config\ScopeConfigInterface;
13+
use Magento\Framework\App\Config\Value;
14+
use Magento\Framework\Data\Collection\AbstractDb;
15+
use Magento\Framework\Exception\LocalizedException;
16+
use Magento\Framework\Model\Context;
17+
use Magento\Framework\Model\ResourceModel\AbstractResource;
18+
use Magento\Framework\Registry;
19+
20+
/**
21+
* Backend source for weight unit configuration field
22+
*/
23+
class WeightUnit extends Value
24+
{
25+
/**
26+
* @var Source
27+
*/
28+
private $source;
29+
30+
/**
31+
* @param Source $source
32+
* @param Context $context
33+
* @param Registry $registry
34+
* @param ScopeConfigInterface $config
35+
* @param TypeListInterface $cacheTypeList
36+
* @param AbstractResource $resource
37+
* @param AbstractDb $resourceCollection
38+
* @param array $data
39+
*
40+
* @codeCoverageIgnore
41+
*/
42+
public function __construct(
43+
Source $source,
44+
Context $context,
45+
Registry $registry,
46+
ScopeConfigInterface $config,
47+
TypeListInterface $cacheTypeList,
48+
AbstractResource $resource = null,
49+
AbstractDb $resourceCollection = null,
50+
array $data = []
51+
) {
52+
$this->source = $source;
53+
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
54+
}
55+
56+
/**
57+
* Check whether weight unit value is acceptable or not
58+
*
59+
* @return $this
60+
*/
61+
public function beforeSave()
62+
{
63+
if ($this->isValueChanged()) {
64+
$weightUnit = $this->getData('value');
65+
if (!in_array($weightUnit, $this->getOptions())) {
66+
throw new LocalizedException(__('There was an error save new configuration value.'));
67+
}
68+
}
69+
70+
return parent::beforeSave();
71+
}
72+
73+
/**
74+
* Get available options for weight unit
75+
*
76+
* @return array
77+
*/
78+
private function getOptions()
79+
{
80+
$options = $this->source->toOptionArray();
81+
82+
return array_column($options, 'value');
83+
}
84+
}

app/code/Magento/Directory/etc/adminhtml/system.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
<field id="weight_unit" translate="label" type="select" sortOrder="7" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
158158
<label>Weight Unit</label>
159159
<source_model>Magento\Directory\Model\Config\Source\WeightUnit</source_model>
160+
<backend_model>Magento\Directory\Model\Config\Backend\WeightUnit</backend_model>
160161
</field>
161162
</group>
162163
</section>

app/code/Magento/Email/Model/Template/Config.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Email\Model\Template;
77

8+
use Magento\Email\Model\Template\Config\UnexpectedTemplateFieldNameValueException;
9+
use Magento\Email\Model\Template\Config\UnexpectedTemplateIdValueException;
810
use Magento\Framework\Filesystem\Directory\ReadFactory;
911
use Magento\Framework\View\Design\Theme\ThemePackageList;
1012

@@ -218,17 +220,17 @@ public function getTemplateFilename($templateId, $designParams = [])
218220
* @param string $templateId Name of an email template
219221
* @param string $fieldName Name of a field value of which to return
220222
* @return string
221-
* @throws \UnexpectedValueException
223+
* @throws UnexpectedTemplateIdValueException|UnexpectedTemplateFieldNameValueException
222224
*/
223225
protected function _getInfo($templateId, $fieldName)
224226
{
225227
$data = $this->_dataStorage->get();
226228
if (!isset($data[$templateId])) {
227-
throw new \UnexpectedValueException("Email template '{$templateId}' is not defined.");
229+
throw new UnexpectedTemplateIdValueException(__("Email template is not defined."));
228230
}
229231
if (!isset($data[$templateId][$fieldName])) {
230-
throw new \UnexpectedValueException(
231-
"Field '{$fieldName}' is not defined for email template '{$templateId}'."
232+
throw new UnexpectedTemplateFieldNameValueException(
233+
"Field '{$fieldName}' is not defined for email template."
232234
);
233235
}
234236
return $data[$templateId][$fieldName];
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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\Email\Model\Template\Config;
9+
10+
/**
11+
* Throw exception if email template has unexpected field name value
12+
*/
13+
class UnexpectedTemplateFieldNameValueException extends \UnexpectedValueException
14+
{
15+
/**
16+
* Exception trace
17+
*
18+
* @return string
19+
*/
20+
public function __toString(): string
21+
{
22+
return preg_replace(
23+
"/(Stack trace:).*$/s",
24+
"$1" . PHP_EOL . "#0 {main}",
25+
parent::__toString()
26+
);
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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\Email\Model\Template\Config;
9+
10+
/**
11+
* Throw exception if email template has unexpected template id value
12+
*/
13+
class UnexpectedTemplateIdValueException extends \UnexpectedValueException
14+
{
15+
/**
16+
* Exception trace
17+
*
18+
* @return string
19+
*/
20+
public function __toString(): string
21+
{
22+
return preg_replace(
23+
"/(Stack trace:).*$/s",
24+
"$1" . PHP_EOL . "#0 {main}",
25+
parent::__toString()
26+
);
27+
}
28+
}

app/code/Magento/Email/Test/Unit/Model/Template/ConfigTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
class ConfigTest extends TestCase
2424
{
25+
/**
26+
* @var array
27+
*/
2528
private $designParams = [
2629
'area' => Area::AREA_FRONTEND,
2730
'theme' => 'Magento/blank',
@@ -310,7 +313,7 @@ public function testGetTemplateFilenameWrongFileName(): void
310313
public function testGetterMethodUnknownTemplate($getterMethod, $argument = null)
311314
{
312315
$this->expectException('UnexpectedValueException');
313-
$this->expectExceptionMessage('Email template \'unknown\' is not defined');
316+
$this->expectExceptionMessage('Email template is not defined');
314317
if (!$argument) {
315318
$this->model->{$getterMethod}('unknown');
316319
} else {
@@ -374,21 +377,21 @@ public function testGetterMethodUnknownField(
374377
public function getterMethodUnknownFieldDataProvider()
375378
{
376379
return [
377-
'label getter' => ['getTemplateLabel', "Field 'label' is not defined for email template 'fixture'."],
378-
'type getter' => ['getTemplateType', "Field 'type' is not defined for email template 'fixture'."],
380+
'label getter' => ['getTemplateLabel', "Field 'label' is not defined for email template."],
381+
'type getter' => ['getTemplateType', "Field 'type' is not defined for email template."],
379382
'module getter' => [
380383
'getTemplateModule',
381-
"Field 'module' is not defined for email template 'fixture'.",
384+
"Field 'module' is not defined for email template.",
382385
],
383386
'file getter, unknown module' => [
384387
'getTemplateFilename',
385-
"Field 'module' is not defined for email template 'fixture'.",
388+
"Field 'module' is not defined for email template.",
386389
[],
387390
$this->designParams,
388391
],
389392
'file getter, unknown file' => [
390393
'getTemplateFilename',
391-
"Field 'file' is not defined for email template 'fixture'.",
394+
"Field 'file' is not defined for email template.",
392395
['module' => 'Fixture_Module'],
393396
$this->designParams,
394397
],

app/code/Magento/Email/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,4 @@ Action,Action
9999
"Header Template","Header Template"
100100
"Footer Template","Footer Template"
101101
"Unable to send mail. Please try again later.","Unable to send mail. Please try again later."
102+
"Email template is not defined.","Email template is not defined."

app/code/Magento/Sales/etc/acl.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<resource id="Magento_Sales::sales_order" title="Orders" translate="title" sortOrder="10">
1515
<resource id="Magento_Sales::actions" title="Actions" translate="title" sortOrder="10">
1616
<resource id="Magento_Sales::create" title="Create" translate="title" sortOrder="10" />
17+
<resource id="Magento_Sales::api_actions" title="Order Save API" translate="title" sortOrder="10" />
1718
<resource id="Magento_Sales::actions_view" title="View" translate="title" sortOrder="20" />
1819
<resource id="Magento_Sales::email" title="Send Order Email" translate="title" sortOrder="30" />
1920
<resource id="Magento_Sales::reorder" title="Reorder" translate="title" sortOrder="40" />

app/code/Magento/Sales/etc/webapi.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@
256256
<route url="/V1/orders" method="POST">
257257
<service class="Magento\Sales\Api\OrderRepositoryInterface" method="save"/>
258258
<resources>
259-
<resource ref="Magento_Sales::create" />
259+
<resource ref="Magento_Sales::api_actions" />
260260
</resources>
261261
</route>
262262
<route url="/V1/transactions/:id" method="GET">

dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ public function testIsValidForSend()
757757
public function testGetTypeNonExistentType()
758758
{
759759
$this->expectException(\UnexpectedValueException::class);
760-
$this->expectExceptionMessage('Email template \'foo\' is not defined.');
760+
$this->expectExceptionMessage('Email template is not defined.');
761761

762762
$this->mockModel();
763763
$this->model->setId('foo');

lib/internal/Magento/Framework/DB/Adapter/SqlVersionProvider.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ class SqlVersionProvider
2323

2424
public const MYSQL_5_7_VERSION = '5.7.';
2525

26+
/**
27+
* @deprecated MARIA_DB_10_VERSION const
28+
* @see isMysqlGte8029(), isMariaDbEngine()
29+
*/
30+
public const MARIA_DB_10_VERSION = '10.';
31+
2632
public const MARIA_DB_10_4_VERSION = '10.4.';
2733

2834
public const MARIA_DB_10_6_VERSION = '10.6.';

0 commit comments

Comments
 (0)