Skip to content

Commit 7b03070

Browse files
authored
Merge pull request #6763 from magento-tsg/2.4.3-develop-pr132
[Condor] Fixes for 2.4 (pr132) (2.4.3-develop)
2 parents 0192ea0 + 0417d7f commit 7b03070

File tree

12 files changed

+316
-11
lines changed

12 files changed

+316
-11
lines changed

app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public function validate(Observer $observer)
185185
* Check item for options
186186
*/
187187
if ($options) {
188-
$qty = $product->getTypeInstance()->prepareQuoteItemQty($qty, $product);
188+
$qty = $product->getTypeInstance()->prepareQuoteItemQty($quoteItem->getQty(), $product);
189189
$quoteItem->setData('qty', $qty);
190190
if ($stockStatus) {
191191
$this->checkOptionsQtyIncrements($quoteItem, $options);

app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/Option.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function initialize(
120120
/**
121121
* if option's qty was updates we also need to update quote item qty
122122
*/
123-
$quoteItem->setData('qty', (int) $qty);
123+
$quoteItem->setData('qty', (int) $result->getItemQty());
124124
}
125125
if ($result->getMessage() !== null) {
126126
$option->setMessage($result->getMessage());

app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/OptionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected function setUp(): void
125125
);
126126
$this->resultMock = $this->getMockBuilder(DataObject::class)
127127
->addMethods(
128-
['getItemIsQtyDecimal', 'getHasQtyOptionUpdate', 'getOrigQty', 'getMessage', 'getItemBackorders']
128+
['getItemIsQtyDecimal', 'getHasQtyOptionUpdate', 'getOrigQty', 'getMessage', 'getItemBackorders', 'getItemQty']
129129
)
130130
->disableOriginalConstructor()
131131
->getMock();
@@ -217,6 +217,7 @@ public function testInitializeWhenResultIsDecimalGetBackordersMessageHasOptionQt
217217
$this->optionMock->expects($this->once())->method('setBackorders')->with('backorders');
218218

219219
$this->stockItemMock->expects($this->once())->method('unsIsChildItem');
220+
$this->resultMock->expects($this->once())->method('getItemQty')->willReturn($qty);
220221
$this->validator->initialize($this->optionMock, $this->quoteItemMock, $qty);
221222
}
222223

app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/QuantityValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ private function createInitialStub($qty)
564564
$this->quoteItemMock->expects($this->any())
565565
->method('getQuote')
566566
->willReturn($this->quoteMock);
567-
$this->quoteItemMock->expects($this->once())
567+
$this->quoteItemMock->expects($this->any())
568568
->method('getQty')
569569
->willReturn($qty);
570570
$this->quoteItemMock->expects($this->any())

app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\App\ObjectManager;
1111
use Magento\Framework\Config\Dom\ValidationException;
1212
use Magento\Framework\Config\Dom\ValidationSchemaException;
13+
use Magento\Cms\Model\Page\CustomLayout\CustomLayoutValidator;
1314

1415
/**
1516
* Controller helper for user input.
@@ -36,23 +37,32 @@ class PostDataProcessor
3637
*/
3738
private $validationState;
3839

40+
/**
41+
* @var CustomLayoutValidator
42+
*/
43+
private $customLayoutValidator;
44+
3945
/**
4046
* @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
4147
* @param \Magento\Framework\Message\ManagerInterface $messageManager
4248
* @param \Magento\Framework\View\Model\Layout\Update\ValidatorFactory $validatorFactory
43-
* @param DomValidationState $validationState
49+
* @param DomValidationState|null $validationState
50+
* @param CustomLayoutValidator|null $customLayoutValidator
4451
*/
4552
public function __construct(
4653
\Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter,
4754
\Magento\Framework\Message\ManagerInterface $messageManager,
4855
\Magento\Framework\View\Model\Layout\Update\ValidatorFactory $validatorFactory,
49-
DomValidationState $validationState = null
56+
DomValidationState $validationState = null,
57+
CustomLayoutValidator $customLayoutValidator = null
5058
) {
5159
$this->dateFilter = $dateFilter;
5260
$this->messageManager = $messageManager;
5361
$this->validatorFactory = $validatorFactory;
5462
$this->validationState = $validationState
5563
?: ObjectManager::getInstance()->get(DomValidationState::class);
64+
$this->customLayoutValidator = $customLayoutValidator
65+
?: ObjectManager::getInstance()->get(CustomLayoutValidator::class);
5666
}
5767

5868
/**
@@ -146,6 +156,9 @@ private function validateData($data, $layoutXmlValidator)
146156
) {
147157
return false;
148158
}
159+
if (!$this->customLayoutValidator->validate($data)) {
160+
return false;
161+
}
149162
} catch (ValidationException $e) {
150163
return false;
151164
} catch (ValidationSchemaException $e) {
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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\Cms\Model\Page\CustomLayout;
9+
10+
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\Framework\Message\ManagerInterface;
12+
use Magento\Cms\Model\PageRepository;
13+
14+
/**
15+
* Class for layout update validation
16+
*/
17+
class CustomLayoutValidator
18+
{
19+
/**
20+
* @var PageFactory
21+
*/
22+
private $pageFactory;
23+
24+
/**
25+
* @var ManagerInterface
26+
*/
27+
private $messageManager;
28+
29+
/**
30+
* CustomLayoutValidator constructor.
31+
* @param PageRepository $pageFactory
32+
* @param ManagerInterface $messageManager
33+
*/
34+
public function __construct(
35+
PageRepository $pageFactory,
36+
ManagerInterface $messageManager
37+
) {
38+
$this->pageFactory = $pageFactory;
39+
$this->messageManager = $messageManager;
40+
}
41+
42+
/**
43+
* Validates layout update and custom layout update for CMS page
44+
*
45+
* @param array $data
46+
* @return bool
47+
* @throws LocalizedException
48+
*/
49+
public function validate(array $data) : bool
50+
{
51+
[$layoutUpdate, $customLayoutUpdate, $oldLayoutUpdate, $oldCustomLayoutUpdate] = $this->getLayoutUpdates($data);
52+
if (isset($data['page_id'])) {
53+
if ($layoutUpdate && $oldLayoutUpdate !== $layoutUpdate
54+
|| $customLayoutUpdate && $oldCustomLayoutUpdate !== $customLayoutUpdate
55+
) {
56+
throw new LocalizedException(__('Custom layout update text cannot be changed, only removed'));
57+
}
58+
} else {
59+
if ($layoutUpdate || $customLayoutUpdate) {
60+
throw new LocalizedException(__('Custom layout update text cannot be changed, only removed'));
61+
}
62+
}
63+
return true;
64+
}
65+
66+
/**
67+
* Gets page layout update values
68+
*
69+
* @param array $data
70+
* @return array
71+
* @throws \Magento\Framework\Exception\NoSuchEntityException
72+
*/
73+
private function getLayoutUpdates(array $data) : array
74+
{
75+
$layoutUpdate = $data['layout_update_xml'] ?? null;
76+
$customLayoutUpdate = $data['custom_layout_update_xml'] ?? null;
77+
$oldLayoutUpdate = null;
78+
$oldCustomLayoutUpdate = null;
79+
if (isset($data['page_id'])) {
80+
$page = $this->pageFactory->getById($data['page_id']);
81+
$oldLayoutUpdate = $page->getId() ? $page->getLayoutUpdateXml() : null;
82+
$oldCustomLayoutUpdate = $page->getId() ? $page->getCustomLayoutUpdateXml() : null;
83+
}
84+
85+
return [$layoutUpdate, $customLayoutUpdate, $oldLayoutUpdate, $oldCustomLayoutUpdate];
86+
}
87+
}

app/code/Magento/Customer/Model/Plugin/UpdateCustomer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public function beforeSave(
4444
?string $passwordHash = null
4545
): array {
4646
$customerId = $this->request->getParam('customerId');
47-
48-
if ($customerId) {
47+
$bodyParams = $this->request->getBodyParams();
48+
if (!isset($bodyParams['customer']['Id']) && $customerId) {
4949
$customer = $this->getUpdatedCustomer($customerRepository->getById($customerId), $customer);
5050
}
5151

app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,7 @@ public function setShippingItemsInformation($info)
508508
protected function _addShippingItem($quoteItemId, $data)
509509
{
510510
$qty = isset($data['qty']) ? (int)$data['qty'] : 1;
511-
//$qty = $qty > 0 ? $qty : 1;
512-
$addressId = isset($data['address']) ? $data['address'] : false;
511+
$addressId = isset($data['address']) ? (int)$data['address'] : false;
513512
$quoteItem = $this->getQuote()->getItemById($quoteItemId);
514513

515514
if ($addressId && $quoteItem) {
@@ -1119,7 +1118,7 @@ function ($address) {
11191118
$this->getCustomer()->getAddresses()
11201119
);
11211120

1122-
return !is_numeric($addressId) || in_array($addressId, $applicableAddressIds);
1121+
return in_array($addressId, $applicableAddressIds);
11231122
}
11241123

11251124
/**

app/code/Magento/Paypal/etc/csp_whitelist.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
<values>
3030
<value id="www_paypal" type="host">www.paypal.com</value>
3131
<value id="www_sandbox_paypal" type="host">www.sandbox.paypal.com</value>
32+
<value id="www_pilot_payflowlink_paypal" type="host">pilot-payflowlink.paypal.com</value>
33+
</values>
34+
</policy>
35+
<policy id="form-action">
36+
<values>
37+
<value id="www_pilot_payflowlink_paypal" type="host">pilot-payflowlink.paypal.com</value>
3238
</values>
3339
</policy>
3440
</policies>

dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,4 +388,28 @@ protected function resetTokenForCustomer($username, $password)
388388
$this->token = $this->tokenService->createCustomerAccessToken($username, $password);
389389
$this->customerRegistry->remove($this->customerRepository->get($username)->getId());
390390
}
391+
392+
/**
393+
* @magentoApiDataFixture Magento/Customer/_files/customer_one_address.php
394+
*/
395+
public function testGetOtherCustomerInfo()
396+
{
397+
$this->_markTestAsRestOnly();
398+
$serviceInfo = [
399+
'rest' => [
400+
'resourcePath' => "/V1/customers/me?customerId=1",
401+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT,
402+
'token' => $this->token,
403+
]
404+
];
405+
$requestData = ['customer' => ["id" => "-1", "Id" => "1"]];
406+
try {
407+
$this->_webApiCall($serviceInfo, $requestData);
408+
} catch (\Throwable $exception) {
409+
if ($restResponse = json_decode($exception->getMessage(), true)) {
410+
$exceptionMessage = $restResponse['message'];
411+
}
412+
}
413+
$this->assertEquals('The customer email is missing. Enter and try again.', $exceptionMessage);
414+
}
391415
}

0 commit comments

Comments
 (0)