Skip to content

Commit 5a689f6

Browse files
Merge pull request #9756 from magento-cia/cia-2.4.9-alpha1-develop-bugfix-04282025
Cia 2.4.9-alpha1-develop Bugfix 04282025
2 parents c0d6865 + 86bb06b commit 5a689f6

File tree

5 files changed

+104
-67
lines changed

5 files changed

+104
-67
lines changed

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/Quote/Plugin/ValidateQuoteOrigOrder.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
<?php
2-
/**
3-
* Copyright 2024 Adobe
2+
/************************************************************************
3+
* Copyright 2025 Adobe
44
* All Rights Reserved.
5+
*
6+
* NOTICE: All information contained herein is, and remains
7+
* the property of Adobe and its suppliers, if any. The intellectual
8+
* and technical concepts contained herein are proprietary to Adobe
9+
* and its suppliers and are protected by all applicable intellectual
10+
* property laws, including trade secret and copyright laws.
11+
* Dissemination of this information or reproduction of this material
12+
* is strictly forbidden unless prior written permission is obtained
13+
* from Adobe.
14+
* ***********************************************************************
515
*/
616

717
declare(strict_types=1);
@@ -45,10 +55,10 @@ public function beforeSave(
4555
CartRepositoryInterface $cartRepository,
4656
CartInterface $quote
4757
): void {
48-
if ($orderId = $quote->getOrigOrderId()) {
49-
$order = $this->orderRepository->get($orderId);
58+
if ($quote->getOrigOrderId() && $quote->getCustomerId()) {
59+
$order = $this->orderRepository->get((int)$quote->getOrigOrderId());
5060
$orderCustomer = (int)$order->getCustomerId();
51-
if ($quote->getCustomerId() !== $orderCustomer) {
61+
if ((int)$quote->getCustomerId() !== $orderCustomer) {
5262
throw new NoSuchEntityException(__('Please check input parameters.'));
5363
}
5464
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,7 @@
184184
</argument>
185185
</arguments>
186186
</type>
187+
<type name="Magento\Quote\Api\CartRepositoryInterface">
188+
<plugin name="quoteValidateOrderId" type="Magento\Quote\Plugin\ValidateQuoteOrigOrder"/>
189+
</type>
187190
</config>

app/code/Magento/Quote/etc/webapi_rest/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
<plugin name="updateQuoteStoreId" type="Magento\Quote\Model\Quote\Plugin\UpdateQuoteStoreId" />
2121
<plugin name="validateQuoteAddress" type="Magento\Quote\Plugin\QuoteAddress" />
2222
</type>
23-
<type name="Magento\Quote\Api\CartRepositoryInterface">
24-
<plugin name="quoteValidateOrderId" type="Magento\Quote\Plugin\ValidateQuoteOrigOrder"/>
25-
</type>
2623
<type name="Magento\Quote\Model\QuoteValidator">
2724
<plugin name="error_redirect_processor" type="Magento\Quote\Plugin\Webapi\Model\ErrorRedirectProcessor" />
2825
</type>

0 commit comments

Comments
 (0)