Skip to content

Commit 202cd02

Browse files
committed
Merge remote-tracking branch 'commerce/2.4.4-develop' into ph-delivery
2 parents 43d0077 + 031fe7e commit 202cd02

File tree

70 files changed

+1700
-250
lines changed

Some content is hidden

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

70 files changed

+1700
-250
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/Catalog/etc/acl.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<resource id="Magento_Catalog::catalog" title="Catalog" translate="title" sortOrder="30">
1313
<resource id="Magento_Catalog::catalog_inventory" title="Inventory" translate="title" sortOrder="10">
1414
<resource id="Magento_Catalog::products" title="Products" translate="title" sortOrder="10">
15-
<resource id="Magento_Catalog::update_attributes" title="Update Attributes" translate="title" sortOrder="10" />
15+
<resource id="Magento_Catalog::update_attributes" title="Mass Update Attributes" translate="title" sortOrder="10" />
1616
<resource id="Magento_Catalog::edit_product_design" title="Edit Product Design" translate="title" sortOrder="20" />
1717
</resource>
1818
<resource id="Magento_Catalog::categories" title="Categories" translate="title" sortOrder="20">
@@ -27,7 +27,7 @@
2727
</resource>
2828
</resource>
2929
<resource id="Magento_Backend::stores_attributes">
30-
<resource id="Magento_Catalog::attributes_attributes" title="Product" translate="title" sortOrder="30" />
30+
<resource id="Magento_Catalog::attributes_attributes" title="Product" translate="title" sortOrder="30"/>
3131
<resource id="Magento_Catalog::sets" title="Attribute Set" translate="title" sortOrder="40"/>
3232
</resource>
3333
</resource>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Quantity,Quantity
148148
Edit,Edit
149149
"Are you sure?","Are you sure?"
150150
"Change Status","Change Status"
151-
"Update Attributes","Update Attributes"
151+
"Mass Update Attributes","Mass Update Attributes"
152152
"start typing to search category","start typing to search category"
153153
"New Category","New Category"
154154
"Images (.gif, .jpg, .png)","Images (.gif, .jpg, .png)"

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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)