Skip to content

Commit 4f82be7

Browse files
authored
Merge pull request magento#9852 from magento-gl/2.4.9-alpha1-develop-sync
2.4.9 alpha1 develop sync
2 parents 77c589a + 41957e6 commit 4f82be7

File tree

26 files changed

+352
-174
lines changed

26 files changed

+352
-174
lines changed

app/code/Magento/Backend/Test/Mftf/Data/BackenedData.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
/**
4-
* Copyright 2018 Adobe
4+
* Copyright 2025 Adobe
55
* All Rights Reserved.
66
*/
77
-->

app/code/Magento/Catalog/Helper/Category.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
use Magento\Catalog\Model\CategoryFactory;
1111
use Magento\Framework\App\Helper\AbstractHelper;
1212
use Magento\Framework\App\Helper\Context;
13+
use Magento\Framework\App\ObjectManager;
1314
use Magento\Framework\Data\CollectionFactory;
1415
use Magento\Framework\Data\Tree\Node\Collection;
16+
use Magento\Framework\Escaper;
1517
use Magento\Framework\Exception\NoSuchEntityException;
1618
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1719
use Magento\Store\Model\ScopeInterface;
@@ -63,24 +65,33 @@ class Category extends AbstractHelper implements ResetAfterRequestInterface
6365
*/
6466
protected $categoryRepository;
6567

68+
/**
69+
* @var Escaper|null
70+
*/
71+
private ?Escaper $escaper;
72+
6673
/**
6774
* @param Context $context
6875
* @param CategoryFactory $categoryFactory
6976
* @param StoreManagerInterface $storeManager
7077
* @param CollectionFactory $dataCollectionFactory
7178
* @param CategoryRepositoryInterface $categoryRepository
79+
* @param Escaper|null $escaper
7280
*/
7381
public function __construct(
7482
Context $context,
7583
CategoryFactory $categoryFactory,
7684
StoreManagerInterface $storeManager,
7785
CollectionFactory $dataCollectionFactory,
78-
CategoryRepositoryInterface $categoryRepository
86+
CategoryRepositoryInterface $categoryRepository,
87+
?Escaper $escaper = null
7988
) {
8089
$this->_categoryFactory = $categoryFactory;
8190
$this->_storeManager = $storeManager;
8291
$this->_dataCollectionFactory = $dataCollectionFactory;
8392
$this->categoryRepository = $categoryRepository;
93+
$this->escaper = $escaper ?: ObjectManager::getInstance()->get(Escaper::class);
94+
8495
parent::__construct($context);
8596
}
8697

@@ -204,6 +215,7 @@ public function getCanonicalUrl(string $categoryUrl): string
204215
if ($params && isset($params['p'])) {
205216
$categoryUrl = $categoryUrl . '?p=' . $params['p'];
206217
}
207-
return $categoryUrl;
218+
219+
return $this->escaper->escapeUrl($categoryUrl);
208220
}
209221
}

app/code/Magento/Catalog/Test/Unit/Helper/CategoryTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\App\Helper\Context;
1515
use Magento\Framework\App\RequestInterface;
1616
use Magento\Framework\Data\CollectionFactory;
17+
use Magento\Framework\Escaper;
1718
use Magento\Store\Model\StoreManagerInterface;
1819
use PHPUnit\Framework\MockObject\MockObject;
1920
use PHPUnit\Framework\TestCase;
@@ -63,6 +64,11 @@ class CategoryTest extends TestCase
6364
*/
6465
private $requestMock;
6566

67+
/**
68+
* @var Escaper|MockObject
69+
*/
70+
private $escaper;
71+
6672
protected function setUp(): void
6773
{
6874
$this->mockContext();
@@ -78,12 +84,16 @@ protected function setUp(): void
7884
$this->categoryRepository = $this->getMockBuilder(CategoryRepositoryInterface::class)
7985
->disableOriginalConstructor()
8086
->getMock();
87+
$this->escaper = $this->getMockBuilder(Escaper::class)
88+
->disableOriginalConstructor()
89+
->getMock();
8190
$this->categoryHelper = new Category(
8291
$this->context,
8392
$this->categoryFactory,
8493
$this->storeManager,
8594
$this->collectionFactory,
86-
$this->categoryRepository
95+
$this->categoryRepository,
96+
$this->escaper
8797
);
8898
}
8999

@@ -101,6 +111,9 @@ public function testGetCanonicalUrl(mixed $params, string $categoryUrl, string $
101111
$this->requestMock->expects($this->any())
102112
->method('getParams')
103113
->willReturn($params);
114+
$this->escaper->expects($this->any())
115+
->method('escapeUrl')
116+
->willReturn($expectedCategoryUrl);
104117
$actualCategoryUrl = $this->categoryHelper->getCanonicalUrl($categoryUrl);
105118
$this->assertEquals($actualCategoryUrl, $expectedCategoryUrl);
106119
}

app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/DataProviderTest.php

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright 2016 Adobe
3+
* Copyright 2025 Adobe
44
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
@@ -12,7 +12,7 @@
1212
use Magento\Framework\Api\Search\SearchCriteriaBuilder;
1313
use Magento\Framework\App\ObjectManager;
1414
use Magento\Framework\App\RequestInterface;
15-
use Magento\Framework\Authorization;
15+
use Magento\Framework\AuthorizationInterface;
1616
use Magento\Framework\ObjectManagerInterface;
1717
use Magento\Framework\View\Element\UiComponent\DataProvider\Reporting;
1818
use Magento\Ui\Component\Container;
@@ -23,49 +23,49 @@
2323
class DataProviderTest extends TestCase
2424
{
2525
/**
26-
* @var Authorization|MockObject
26+
* @var AuthorizationInterface|MockObject
2727
*/
28-
private $authorizationMock;
28+
private AuthorizationInterface|MockObject $authorizationMock;
2929

3030
/**
3131
* @var Reporting|MockObject
3232
*/
33-
private $reportingMock;
33+
private Reporting|MockObject $reportingMock;
3434

3535
/**
3636
* @var SearchCriteriaBuilder|MockObject
3737
*/
38-
private $searchCriteriaBuilderMock;
38+
private SearchCriteriaBuilder|MockObject $searchCriteriaBuilderMock;
3939

4040
/**
4141
* @var RequestInterface|MockObject
4242
*/
43-
private $requestInterfaceMock;
43+
private RequestInterface|MockObject $requestInterfaceMock;
4444

4545
/**
4646
* @var FilterBuilder|MockObject
4747
*/
48-
private $filterBuilderMock;
48+
private FilterBuilder|MockObject $filterBuilderMock;
4949

5050
/**
5151
* @var DataProvider
5252
*/
53-
private $dataProvider;
53+
private DataProvider $dataProvider;
5454

5555
/**
5656
* @var string
5757
*/
58-
private $name = 'cms_page_listing_data_source';
58+
private string $name = 'cms_page_listing_data_source';
5959

6060
/**
6161
* @var string
6262
*/
63-
private $primaryFieldName = 'page';
63+
private string $primaryFieldName = 'page';
6464

6565
/**
6666
* @var string
6767
*/
68-
private $requestFieldName = 'id';
68+
private string $requestFieldName = 'id';
6969

7070
/**
7171
* @var array
@@ -80,30 +80,20 @@ class DataProviderTest extends TestCase
8080

8181
protected function setUp(): void
8282
{
83-
$this->authorizationMock = $this->getMockBuilder(Authorization::class)
84-
->disableOriginalConstructor()
85-
->getMock();
83+
$this->authorizationMock = $this->createMock(AuthorizationInterface::class);
8684

87-
$this->reportingMock = $this->getMockBuilder(Reporting::class)
88-
->disableOriginalConstructor()
89-
->getMock();
85+
$this->reportingMock = $this->createMock(Reporting::class);
9086

91-
$this->searchCriteriaBuilderMock = $this->getMockBuilder(SearchCriteriaBuilder::class)
92-
->disableOriginalConstructor()
93-
->getMock();
87+
$this->searchCriteriaBuilderMock = $this->createMock(SearchCriteriaBuilder::class);
9488

95-
$this->requestInterfaceMock = $this->getMockBuilder(RequestInterface::class)
96-
->disableOriginalConstructor()
97-
->getMockForAbstractClass();
89+
$this->requestInterfaceMock = $this->createMock(RequestInterface::class);
9890

99-
$this->filterBuilderMock = $this->getMockBuilder(FilterBuilder::class)
100-
->disableOriginalConstructor()
101-
->getMock();
91+
$this->filterBuilderMock = $this->createMock(FilterBuilder::class);
10292

10393
/** @var ObjectManagerInterface|MockObject $objectManagerMock */
104-
$objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
105-
$objectManagerMock->expects($this->once())
106-
->method('get')
94+
$objectManagerMock = $this->createMock(ObjectManagerInterface::class);
95+
$objectManagerMock->method('get')
96+
->with(AuthorizationInterface::class)
10797
->willReturn($this->authorizationMock);
10898
ObjectManager::setInstance($objectManagerMock);
10999

@@ -121,15 +111,14 @@ protected function setUp(): void
121111
/**
122112
* @covers \Magento\Cms\Ui\Component\DataProvider::prepareMetadata
123113
*/
124-
public function testPrepareMetadata()
114+
public function testPrepareMetadata(): void
125115
{
126116
$this->authorizationMock->expects($this->exactly(2))
127117
->method('isAllowed')
128118
->willReturnMap(
129119
[
130120
['Magento_Cms::save', null, false],
131121
['Magento_Cms::save_design', null, false],
132-
133122
]
134123
);
135124

@@ -168,4 +157,24 @@ public function testPrepareMetadata()
168157
$this->dataProvider->prepareMetadata()
169158
);
170159
}
160+
161+
/**
162+
* @covers \Magento\Cms\Ui\Component\DataProvider::prepareMetadata
163+
*/
164+
public function testPrepareMetadataForCmsBlockListing(): void
165+
{
166+
$name = 'cms_block_listing_data_source';
167+
168+
$this->dataProvider = new DataProvider(
169+
$name,
170+
$this->primaryFieldName,
171+
$this->requestFieldName,
172+
$this->reportingMock,
173+
$this->searchCriteriaBuilderMock,
174+
$this->requestInterfaceMock,
175+
$this->filterBuilderMock
176+
);
177+
178+
$this->assertEquals([], $this->dataProvider->prepareMetadata());
179+
}
171180
}

app/code/Magento/Cms/Ui/Component/DataProvider.php

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,25 @@
1616
use Magento\Ui\Component\Container;
1717

1818
/**
19-
* DataProvider for cms ui.
19+
* DataProvider for cms blocks and pages listing ui components.
2020
*/
2121
class DataProvider extends \Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider
2222
{
23+
/**
24+
* Authorization resource for CMS Save
25+
*/
26+
private const CMS_SAVE_RESOURCE = 'Magento_Cms::save';
27+
28+
/**
29+
* Authorization resource for CMS save design resource
30+
*/
31+
private const CMS_SAVE_DESIGN_RESOURCE = 'Magento_Cms::save_design';
32+
33+
/**
34+
* Constant for CMS listing data source name
35+
*/
36+
private const CMS_LISTING_DATA_SOURCE = 'cms_page_listing_data_source';
37+
2338
/**
2439
* @var AuthorizationInterface
2540
*/
@@ -107,38 +122,41 @@ public function prepareMetadata()
107122
{
108123
$metadata = [];
109124

110-
if (!$this->getAuthorizationInstance()->isAllowed('Magento_Cms::save')) {
111-
$metadata = [
112-
'cms_page_columns' => [
113-
'arguments' => [
114-
'data' => [
115-
'config' => [
116-
'editorConfig' => [
117-
'enabled' => false
118-
],
119-
'componentType' => Container::NAME
125+
if ($this->name === self::CMS_LISTING_DATA_SOURCE) {
126+
127+
if (!$this->getAuthorizationInstance()->isAllowed(self::CMS_SAVE_RESOURCE)) {
128+
$metadata = [
129+
'cms_page_columns' => [
130+
'arguments' => [
131+
'data' => [
132+
'config' => [
133+
'editorConfig' => [
134+
'enabled' => false
135+
],
136+
'componentType' => Container::NAME
137+
]
120138
]
121139
]
122140
]
123-
]
124-
];
125-
}
141+
];
142+
}
143+
144+
if (!$this->getAuthorizationInstance()->isAllowed(self::CMS_SAVE_DESIGN_RESOURCE)) {
126145

127-
if (!$this->getAuthorizationInstance()->isAllowed('Magento_Cms::save_design')) {
128-
129-
foreach ($this->pageLayoutColumns as $column) {
130-
$metadata['cms_page_columns']['children'][$column] = [
131-
'arguments' => [
132-
'data' => [
133-
'config' => [
134-
'editor' => [
135-
'editorType' => false
136-
],
137-
'componentType' => Container::NAME
146+
foreach ($this->pageLayoutColumns as $column) {
147+
$metadata['cms_page_columns']['children'][$column] = [
148+
'arguments' => [
149+
'data' => [
150+
'config' => [
151+
'editor' => [
152+
'editorType' => false
153+
],
154+
'componentType' => Container::NAME
155+
]
138156
]
139157
]
140-
]
141-
];
158+
];
159+
}
142160
}
143161
}
144162

app/code/Magento/Dhl/Model/Carrier.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,11 +1436,12 @@ protected function _getQuotesRest()
14361436
"packages" => [
14371437
[
14381438
"typeCode" => "3BX",
1439-
"weight" => (int) $this->_getWeight($rawRequest->getWeight()),
1439+
"weight" => (float) $this->_getWeight($rawRequest->getWeight()),
14401440
"dimensions" => [
1441-
"length" => $this->_getDimension($this->getConfigData('depth')),
1442-
"width" => $this->_getDimension($this->getConfigData('width')),
1443-
"height" => $this->_getDimension($this->getConfigData('height'))
1441+
// If no value is provided for the dimension, a default size of 3 will be used
1442+
"length" => $this->_getDimension(max(3, $this->getConfigData('depth'))),
1443+
"width" => $this->_getDimension(max(3, $this->getConfigData('width'))),
1444+
"height" => $this->_getDimension(max(3, $this->getConfigData('height')))
14441445
]
14451446
]
14461447
]
@@ -1575,7 +1576,7 @@ protected function _addRestRate(array $product, array $exchangeRates): self
15751576
$dhlProduct = (string)$product['productCode'];
15761577
$totalPrice = $product['totalPrice'];
15771578
$billic_price = array_column(
1578-
array_filter($totalPrice, fn($price) => $price['currencyType'] === 'BILLC'),
1579+
array_filter($totalPrice, fn ($price) => $price['currencyType'] === 'BILLC'),
15791580
'price'
15801581
);
15811582

@@ -2245,7 +2246,7 @@ protected function _doShipmentRequestRest(): DataObject
22452246
"invoice" => [
22462247
"number" => $rawRequest->getOrderShipment()->getOrder()->getIncrementId(),
22472248
"date" => date('Y-m-d')
2248-
]
2249+
]
22492250
]
22502251
];
22512252
}

0 commit comments

Comments
 (0)