Skip to content

Commit f3dbf14

Browse files
Merge branch '2.4.6-develop' into 2.4.6-develop-2.4-develop-sync-12202022
2 parents 5844ade + 58a0fa1 commit f3dbf14

File tree

31 files changed

+1300
-226
lines changed

31 files changed

+1300
-226
lines changed

app/code/Magento/Backend/Block/System/Store/Grid/Render/Group.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Backend\Block\System\Store\Grid\Render;
77

8+
use Magento\Framework\DataObject;
9+
810
/**
911
* Store render group
1012
*
@@ -13,9 +15,9 @@
1315
class Group extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
1416
{
1517
/**
16-
* {@inheritdoc}
18+
* @inheritDoc
1719
*/
18-
public function render(\Magento\Framework\DataObject $row)
20+
public function render(DataObject $row)
1921
{
2022
if (!$row->getData($this->getColumn()->getIndex())) {
2123
return null;
@@ -28,6 +30,6 @@ public function render(\Magento\Framework\DataObject $row)
2830
'">' .
2931
$this->escapeHtml($row->getData($this->getColumn()->getIndex())) .
3032
'</a><br />'
31-
. '(' . __('Code') . ': ' . $row->getGroupCode() . ')';
33+
. '(' . __('Code') . ': ' . $this->escapeHtml($row->getGroupCode()) . ')';
3234
}
3335
}

app/code/Magento/Cms/Controller/Noroute/Index.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
declare(strict_types=1);
8+
79
namespace Magento\Cms\Controller\Noroute;
810

11+
use Magento\Framework\Controller\Result\ForwardFactory;
12+
913
/**
1014
* @SuppressWarnings(PHPMD.AllPurposeAction)
1115
*/
1216
class Index extends \Magento\Framework\App\Action\Action
1317
{
1418
/**
15-
* @var \Magento\Framework\Controller\Result\ForwardFactory
19+
* @var ForwardFactory
1620
*/
17-
protected $resultForwardFactory;
21+
protected ForwardFactory $resultForwardFactory;
1822

1923
/**
2024
* @param \Magento\Framework\App\Action\Context $context
@@ -48,6 +52,7 @@ public function execute()
4852
if ($resultPage) {
4953
$resultPage->setStatusHeader(404, '1.1', 'Not Found');
5054
$resultPage->setHeader('Status', '404 File not found');
55+
$resultPage->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0', true);
5156
return $resultPage;
5257
} else {
5358
/** @var \Magento\Framework\Controller\Result\Forward $resultForward */

app/code/Magento/Cms/Test/Unit/Controller/Noroute/IndexTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ class IndexTest extends TestCase
2929
/**
3030
* @var Index
3131
*/
32-
protected $_controller;
32+
protected Index $_controller;
3333

3434
/**
3535
* @var MockObject
3636
*/
37-
protected $_cmsHelperMock;
37+
protected MockObject $_cmsHelperMock;
3838

3939
/**
4040
* @var MockObject
4141
*/
42-
protected $_requestMock;
42+
protected MockObject $_requestMock;
4343

4444
/**
4545
* @var ForwardFactory|MockObject
@@ -119,10 +119,14 @@ public function testExecuteResultPage(): void
119119
->method('setStatusHeader')
120120
->with(404, '1.1', 'Not Found')
121121
->willReturn($this->resultPageMock);
122+
122123
$this->resultPageMock
123124
->method('setHeader')
124-
->with('Status', '404 File not found')
125-
->willReturn($this->resultPageMock);
125+
->withConsecutive(
126+
['Status', '404 File not found'],
127+
['Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0']
128+
)->willReturn($this->resultPageMock);
129+
126130
$this->_cmsHelperMock->expects(
127131
$this->once()
128132
)->method(

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

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
6+
declare(strict_types=1);
7+
78
namespace Magento\Customer\Controller\Account;
89

910
use Magento\Customer\Api\AccountManagementInterface;
@@ -15,11 +16,15 @@
1516
use Magento\Framework\App\Action\Context;
1617
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
1718
use Magento\Framework\App\Config\ScopeConfigInterface;
19+
use Magento\Framework\App\ObjectManager;
1820
use Magento\Framework\Controller\ResultFactory;
21+
use Magento\Framework\Exception\NoSuchEntityException;
22+
use Magento\Framework\Phrase;
1923
use Magento\Framework\UrlFactory;
2024
use Magento\Framework\Exception\StateException;
2125
use Magento\Store\Model\ScopeInterface;
2226
use Magento\Store\Model\StoreManagerInterface;
27+
use Magento\Customer\Model\Logger as CustomerLogger;
2328

2429
/**
2530
* Class Confirm
@@ -75,6 +80,11 @@ class Confirm extends AbstractAccount implements HttpGetActionInterface
7580
*/
7681
private $cookieMetadataManager;
7782

83+
/**
84+
* @var CustomerLogger
85+
*/
86+
private CustomerLogger $customerLogger;
87+
7888
/**
7989
* @param Context $context
8090
* @param Session $customerSession
@@ -84,6 +94,7 @@ class Confirm extends AbstractAccount implements HttpGetActionInterface
8494
* @param CustomerRepositoryInterface $customerRepository
8595
* @param Address $addressHelper
8696
* @param UrlFactory $urlFactory
97+
* @param CustomerLogger|null $customerLogger
8798
*/
8899
public function __construct(
89100
Context $context,
@@ -93,7 +104,8 @@ public function __construct(
93104
AccountManagementInterface $customerAccountManagement,
94105
CustomerRepositoryInterface $customerRepository,
95106
Address $addressHelper,
96-
UrlFactory $urlFactory
107+
UrlFactory $urlFactory,
108+
?CustomerLogger $customerLogger = null
97109
) {
98110
$this->session = $customerSession;
99111
$this->scopeConfig = $scopeConfig;
@@ -102,13 +114,13 @@ public function __construct(
102114
$this->customerRepository = $customerRepository;
103115
$this->addressHelper = $addressHelper;
104116
$this->urlModel = $urlFactory->create();
117+
$this->customerLogger = $customerLogger ?? ObjectManager::getInstance()->get(CustomerLogger::class);
105118
parent::__construct($context);
106119
}
107120

108121
/**
109122
* Retrieve cookie manager
110123
*
111-
* @deprecated 101.0.0
112124
* @return \Magento\Framework\Stdlib\Cookie\PhpCookieManager
113125
*/
114126
private function getCookieManager()
@@ -124,7 +136,6 @@ private function getCookieManager()
124136
/**
125137
* Retrieve cookie metadata factory
126138
*
127-
* @deprecated 101.0.0
128139
* @return \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
129140
*/
130141
private function getCookieMetadataFactory()
@@ -152,7 +163,7 @@ public function execute()
152163
return $resultRedirect;
153164
}
154165

155-
$customerId = $this->getRequest()->getParam('id', false);
166+
$customerId = $this->getCustomerId();
156167
$key = $this->getRequest()->getParam('key', false);
157168
if (empty($customerId) || empty($key)) {
158169
$this->messageManager->addErrorMessage(__('Bad request.'));
@@ -164,13 +175,19 @@ public function execute()
164175
// log in and send greeting email
165176
$customerEmail = $this->customerRepository->getById($customerId)->getEmail();
166177
$customer = $this->customerAccountManagement->activate($customerEmail, $key);
178+
$successMessage = $this->getSuccessMessage();
167179
$this->session->setCustomerDataAsLoggedIn($customer);
180+
168181
if ($this->getCookieManager()->getCookie('mage-cache-sessid')) {
169182
$metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
170183
$metadata->setPath('/');
171184
$this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);
172185
}
173-
$this->messageManager->addSuccess($this->getSuccessMessage());
186+
187+
if ($successMessage) {
188+
$this->messageManager->addSuccess($successMessage);
189+
}
190+
174191
$resultRedirect->setUrl($this->getSuccessRedirect());
175192
return $resultRedirect;
176193
} catch (StateException $e) {
@@ -183,33 +200,41 @@ public function execute()
183200
return $resultRedirect->setUrl($this->_redirect->error($url));
184201
}
185202

203+
/**
204+
* Returns customer id from request
205+
*
206+
* @return int
207+
*/
208+
private function getCustomerId(): int
209+
{
210+
return (int)$this->getRequest()->getParam('id', 0);
211+
}
212+
186213
/**
187214
* Retrieve success message
188215
*
189-
* @return string
216+
* @return Phrase|null
217+
* @throws NoSuchEntityException
190218
*/
191219
protected function getSuccessMessage()
192220
{
193221
if ($this->addressHelper->isVatValidationEnabled()) {
194-
if ($this->addressHelper->getTaxCalculationAddressType() == Address::TYPE_SHIPPING) {
195-
// @codingStandardsIgnoreStart
196-
$message = __(
197-
'If you are a registered VAT customer, please click <a href="%1">here</a> to enter your shipping address for proper VAT calculation.',
198-
$this->urlModel->getUrl('customer/address/edit')
199-
);
200-
// @codingStandardsIgnoreEnd
201-
} else {
202-
// @codingStandardsIgnoreStart
203-
$message = __(
204-
'If you are a registered VAT customer, please click <a href="%1">here</a> to enter your billing address for proper VAT calculation.',
205-
$this->urlModel->getUrl('customer/address/edit')
206-
);
207-
// @codingStandardsIgnoreEnd
208-
}
209-
} else {
210-
$message = __('Thank you for registering with %1.', $this->storeManager->getStore()->getFrontendName());
222+
return __(
223+
$this->addressHelper->getTaxCalculationAddressType() == Address::TYPE_SHIPPING
224+
? 'If you are a registered VAT customer, please click <a href="%1">here</a> to enter your '
225+
.'shipping address for proper VAT calculation.'
226+
:'If you are a registered VAT customer, please click <a href="%1">here</a> to enter your '
227+
.'billing address for proper VAT calculation.',
228+
$this->urlModel->getUrl('customer/address/edit')
229+
);
211230
}
212-
return $message;
231+
232+
$customerId = $this->getCustomerId();
233+
if ($customerId && $this->customerLogger->get($customerId)->getLastLoginAt()) {
234+
return null;
235+
}
236+
237+
return __('Thank you for registering with %1.', $this->storeManager->getStore()->getFrontendName());
213238
}
214239

215240
/**

0 commit comments

Comments
 (0)