Skip to content

Commit fabd681

Browse files
authored
Merge pull request #7553 from magento-gl/2.4.4-develop-sync-v2
Sync PR between 2.4.4-develop and 2.4-develop
2 parents 07d15f8 + bf9b9d2 commit fabd681

File tree

129 files changed

+3219
-1250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+3219
-1250
lines changed

app/code/Magento/Backend/etc/config.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
<seo>
4545
<use_rewrites>0</use_rewrites>
4646
</seo>
47+
<secure>
48+
<use_in_frontend>1</use_in_frontend>
49+
<use_in_adminhtml>1</use_in_adminhtml>
50+
</secure>
4751
</web>
4852
</default>
4953
<stores>

app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function getValueHtml($item)
151151
{
152152
if ($attributes = $this->getSelectionAttributes($item)) {
153153
return sprintf('%d', $attributes['qty']) . ' x ' . $this->escapeHtml($item->getName()) . " "
154-
. $this->getOrder()->formatBasePrice($attributes['price']);
154+
. $this->getOrder()->formatPrice($attributes['price']);
155155
}
156156
return $this->escapeHtml($item->getName());
157157
}

app/code/Magento/Catalog/view/adminhtml/web/catalog/product/composite/configure.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ define([
230230
if (response.error) {
231231
this.blockMsg.show();
232232
this.blockMsgError.innerHTML = response.message;
233-
this.blockCancelBtn.hide();
233+
if(this.blockCancelBtn) {
234+
this.blockCancelBtn.hide();
235+
}
234236
this.setConfirmCallback(listType, null);
235237
this._showWindow();
236238
}
@@ -584,7 +586,9 @@ define([
584586
this.blockFormFields.update();
585587
this.blockMsg.hide();
586588
this.blockMsgError.update();
587-
this.blockCancelBtn.show();
589+
if(this.blockCancelBtn) {
590+
this.blockCancelBtn.show();
591+
}
588592
break;
589593
default:
590594
// search in list types for its cleaning
@@ -603,7 +607,9 @@ define([
603607
this.blockFormFields.update();
604608
this.blockMsg.hide();
605609
this.blockMsgError.update();
606-
this.blockCancelBtn.show();
610+
if(this.blockCancelBtn) {
611+
this.blockCancelBtn.show();
612+
}
607613
}
608614
break;
609615
}

app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class BlockActions extends Column
2020
/**
2121
* Url path
2222
*/
23-
const URL_PATH_EDIT = 'cms/block/edit';
24-
const URL_PATH_DELETE = 'cms/block/delete';
25-
const URL_PATH_DETAILS = 'cms/block/details';
23+
public const URL_PATH_EDIT = 'cms/block/edit';
24+
public const URL_PATH_DELETE = 'cms/block/delete';
25+
public const URL_PATH_DETAILS = 'cms/block/details';
2626

2727
/**
2828
* @var UrlInterface
@@ -66,24 +66,24 @@ public function prepareDataSource(array $dataSource)
6666
'href' => $this->urlBuilder->getUrl(
6767
static::URL_PATH_EDIT,
6868
[
69-
'block_id' => $item['block_id'],
69+
'block_id' => $item['block_id']
7070
]
7171
),
72-
'label' => __('Edit'),
72+
'label' => __('Edit')
7373
],
7474
'delete' => [
7575
'href' => $this->urlBuilder->getUrl(
7676
static::URL_PATH_DELETE,
7777
[
78-
'block_id' => $item['block_id'],
78+
'block_id' => $item['block_id']
7979
]
8080
),
8181
'label' => __('Delete'),
8282
'confirm' => [
8383
'title' => __('Delete %1', $title),
84-
'message' => __('Are you sure you want to delete a %1 record?', $title),
84+
'message' => __('Are you sure you want to delete a %1 record?', $title)
8585
],
86-
'post' => true,
86+
'post' => true
8787
],
8888
];
8989
}
@@ -102,6 +102,7 @@ public function prepareDataSource(array $dataSource)
102102
private function getEscaper()
103103
{
104104
if (!$this->escaper) {
105+
// phpcs:ignore Magento2.PHP.AutogeneratedClassNotInConstructor
105106
$this->escaper = ObjectManager::getInstance()->get(Escaper::class);
106107
}
107108
return $this->escaper;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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\Contact\Plugin\UserDataProvider;
9+
10+
use Magento\Framework\DataObject;
11+
use Magento\Framework\View\Element\Block\ArgumentInterface;
12+
use Magento\Framework\View\Element\BlockInterface;
13+
14+
/**
15+
* Sets the view model
16+
*/
17+
class ViewModel
18+
{
19+
/**
20+
* Key `view_model`
21+
*/
22+
private const VIEW_MODEL = 'view_model';
23+
24+
/**
25+
* @var ArgumentInterface
26+
*/
27+
private $viewModel;
28+
29+
/**
30+
* @param ArgumentInterface $viewModel
31+
*/
32+
public function __construct(ArgumentInterface $viewModel)
33+
{
34+
$this->viewModel = $viewModel;
35+
}
36+
37+
/**
38+
* Sets the view model before rendering to HTML
39+
*
40+
* @param DataObject|BlockInterface $block
41+
* @return null
42+
*/
43+
public function beforeToHtml(DataObject $block)
44+
{
45+
if (!$block->hasData(self::VIEW_MODEL)) {
46+
$block->setData(self::VIEW_MODEL, $this->viewModel);
47+
}
48+
49+
return null;
50+
}
51+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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\Contact\Test\Unit\Plugin\UserDataProvider;
9+
10+
use Magento\Contact\Plugin\UserDataProvider\ViewModel as ViewModelPlugin;
11+
use Magento\Framework\DataObject;
12+
use Magento\Framework\View\Element\Block\ArgumentInterface;
13+
use PHPUnit\Framework\MockObject\MockObject;
14+
use PHPUnit\Framework\TestCase;
15+
16+
/**
17+
* Unit test for the ViewModelPlugin class
18+
*/
19+
class ViewModelTest extends TestCase
20+
{
21+
/**
22+
* @var ArgumentInterface|MockObject
23+
*/
24+
private $viewModelMock;
25+
26+
/**
27+
* @var DataObject|MockObject
28+
*/
29+
private $blockMock;
30+
31+
/**
32+
* @var ViewModelPlugin
33+
*/
34+
private $plugin;
35+
36+
/**
37+
* @inheritDoc
38+
*/
39+
protected function setUp(): void
40+
{
41+
$this->viewModelMock = $this->getMockForAbstractClass(ArgumentInterface::class);
42+
$this->blockMock = $this->createMock(DataObject::class);
43+
44+
$this->plugin = new ViewModelPlugin($this->viewModelMock);
45+
}
46+
47+
/**
48+
* @dataProvider dataProvider
49+
*/
50+
public function testBeforeToHtml($hasDataResult, $setDataExpects)
51+
{
52+
$this->blockMock->expects($this->once())
53+
->method('hasData')
54+
->with('view_model')
55+
->willReturn($hasDataResult);
56+
57+
$this->blockMock->expects($setDataExpects)
58+
->method('setData')
59+
->with('view_model', $this->viewModelMock);
60+
61+
$this->plugin->beforeToHtml($this->blockMock);
62+
}
63+
64+
public function dataProvider()
65+
{
66+
return [
67+
'view model was not preset before' => [
68+
'hasData' => false,
69+
'setData' => $this->once(),
70+
],
71+
'view model was pre-installed before' => [
72+
'hasData' => true,
73+
'setData' => $this->never(),
74+
]
75+
];
76+
}
77+
}

app/code/Magento/Contact/etc/frontend/di.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,12 @@
1313
</argument>
1414
</arguments>
1515
</type>
16+
<type name="Magento\Contact\Plugin\UserDataProvider\ViewModel">
17+
<arguments>
18+
<argument name="viewModel" xsi:type="object">Magento\Contact\ViewModel\UserDataProvider</argument>
19+
</arguments>
20+
</type>
21+
<type name="Magento\Contact\Block\ContactForm">
22+
<plugin name="set_view_model" type="Magento\Contact\Plugin\UserDataProvider\ViewModel" />
23+
</type>
1624
</config>

app/code/Magento/Contact/view/frontend/layout/contact_index_index.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
<referenceContainer name="content">
1414
<block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml">
1515
<container name="form.additional.info" label="Form Additional Info"/>
16-
<arguments>
17-
<argument name="view_model" xsi:type="object">Magento\Contact\ViewModel\UserDataProvider</argument>
18-
</arguments>
1916
</block>
2017
</referenceContainer>
2118
</body>

app/code/Magento/Customer/Controller/Account/CreatePassword.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\Framework\Controller\Result\Redirect;
1818
use Magento\Framework\View\Result\Page;
1919
use Magento\Framework\View\Result\PageFactory;
20+
use Magento\Customer\Api\CustomerRepositoryInterface;
2021

2122
/**
2223
* Controller for front-end customer password reset form
@@ -48,21 +49,28 @@ class CreatePassword extends \Magento\Customer\Controller\AbstractAccount implem
4849
*/
4950
private $getByToken;
5051

52+
/**
53+
* @var CustomerRepositoryInterface
54+
*/
55+
private $customerRepository;
56+
5157
/**
5258
* @param Context $context
5359
* @param Session $customerSession
5460
* @param PageFactory $resultPageFactory
5561
* @param AccountManagementInterface $accountManagement
5662
* @param ConfirmCustomerByToken|null $confirmByToken
5763
* @param GetCustomerByToken|null $getByToken
64+
* @param CustomerRepositoryInterface|null $customerRepository
5865
*/
5966
public function __construct(
6067
Context $context,
6168
Session $customerSession,
6269
PageFactory $resultPageFactory,
6370
AccountManagementInterface $accountManagement,
6471
ConfirmCustomerByToken $confirmByToken = null,
65-
GetCustomerByToken $getByToken = null
72+
GetCustomerByToken $getByToken = null,
73+
CustomerRepositoryInterface $customerRepository = null
6674
) {
6775
$this->session = $customerSession;
6876
$this->resultPageFactory = $resultPageFactory;
@@ -71,6 +79,8 @@ public function __construct(
7179
?? ObjectManager::getInstance()->get(ConfirmCustomerByToken::class);
7280
$this->getByToken = $getByToken
7381
?? ObjectManager::getInstance()->get(GetCustomerByToken::class);
82+
$this->customerRepository = $customerRepository
83+
?? ObjectManager::getInstance()->get(CustomerRepositoryInterface::class);
7484

7585
parent::__construct($context);
7686
}
@@ -83,23 +93,25 @@ public function __construct(
8393
public function execute()
8494
{
8595
$resetPasswordToken = (string)$this->getRequest()->getParam('token');
96+
$customerId = (int)$this->getRequest()->getParam('id');
8697
$isDirectLink = $resetPasswordToken != '';
8798
if (!$isDirectLink) {
8899
$resetPasswordToken = (string)$this->session->getRpToken();
100+
$customerId = (int)$this->session->getRpCustomerId();
89101
}
90102

91103
try {
92-
$this->accountManagement->validateResetPasswordLinkToken(null, $resetPasswordToken);
93-
94-
$this->confirmByToken->execute($resetPasswordToken);
104+
$this->accountManagement->validateResetPasswordLinkToken($customerId, $resetPasswordToken);
105+
$this->confirmByToken->resetCustomerConfirmation($customerId);
95106

96107
// Extend token validity to avoid expiration while this form is
97108
// being completed by the user.
98-
$customer = $this->getByToken->execute($resetPasswordToken);
109+
$customer = $this->customerRepository->getById($customerId);
99110
$this->accountManagement->changeResetPasswordLinkToken($customer, $resetPasswordToken);
100111

101112
if ($isDirectLink) {
102113
$this->session->setRpToken($resetPasswordToken);
114+
$this->session->setRpCustomerId($customerId);
103115
$resultRedirect = $this->resultRedirectFactory->create();
104116
$resultRedirect->setPath('*/*/createpassword');
105117

@@ -109,7 +121,8 @@ public function execute()
109121
$resultPage = $this->resultPageFactory->create();
110122
$resultPage->getLayout()
111123
->getBlock('resetPassword')
112-
->setResetPasswordLinkToken($resetPasswordToken);
124+
->setResetPasswordLinkToken($resetPasswordToken)
125+
->setRpCustomerId($customerId);
113126

114127
return $resultPage;
115128
}

app/code/Magento/Customer/Controller/Account/ResetPasswordPost.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ public function execute()
6767
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
6868
$resultRedirect = $this->resultRedirectFactory->create();
6969
$resetPasswordToken = (string)$this->getRequest()->getQuery('token');
70+
$customerId = (string)$this->getRequest()->getQuery('id');
7071
$password = (string)$this->getRequest()->getPost('password');
7172
$passwordConfirmation = (string)$this->getRequest()->getPost('password_confirmation');
73+
$email = null;
7274

7375
if ($password !== $passwordConfirmation) {
7476
$this->messageManager->addErrorMessage(__("New Password and Confirm New Password values didn't match."));
@@ -83,9 +85,13 @@ public function execute()
8385
return $resultRedirect;
8486
}
8587

88+
if ($customerId && $this->customerRepository->getById($customerId)) {
89+
$email = $this->customerRepository->getById($customerId)->getEmail();
90+
}
91+
8692
try {
8793
$this->accountManagement->resetPassword(
88-
null,
94+
$email,
8995
$resetPasswordToken,
9096
$password
9197
);
@@ -95,6 +101,7 @@ public function execute()
95101
$this->session->start();
96102
}
97103
$this->session->unsRpToken();
104+
$this->session->unsRpCustomerId();
98105
$this->messageManager->addSuccessMessage(__('You updated your password.'));
99106
$resultRedirect->setPath('*/*/login');
100107

0 commit comments

Comments
 (0)