Skip to content

Commit fd076ae

Browse files
author
Stanislav Idolov
authored
🔃 [EngCom] Public Pull Requests - 2.3-develop
Accepted Public Pull Requests: - #17140: [Forwardport] Replacing Usage of Deprecated Methods for Message Manager (by @gelanivishal) - #17138: [Forwardport]Delete all unused imports of lib/internal/Magento (by @VitaliyBoyko) - #17133: [Forwardport] Remove commented code (by @mage2pratik) - #17123: Refactored multiples conditions which could be grouped in a single on� (by @jochhop) - #16983: Broken Responsive Layout on Top page (by @rodrigoobiassi) - #16697: Update regex in ControllerAclTest (by @aleron75)
2 parents f2fe862 + 6d5e310 commit fd076ae

File tree

78 files changed

+134
-195
lines changed

Some content is hidden

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

78 files changed

+134
-195
lines changed

app/code/Magento/Backend/Block/Dashboard/Bar.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ public function getTotals()
3838
*/
3939
public function addTotal($label, $value, $isQuantity = false)
4040
{
41-
/*if (!$isQuantity) {
42-
$value = $this->format($value);
43-
$decimals = substr($value, -2);
44-
$value = substr($value, 0, -2);
45-
} else {
46-
$value = ($value != '')?$value:0;
47-
$decimals = '';
48-
}*/
4941
if (!$isQuantity) {
5042
$value = $this->format($value);
5143
}

app/code/Magento/Captcha/Observer/CheckGuestCheckoutObserver.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,14 @@ public function execute(\Magento\Framework\Event\Observer $observer)
6666
$formId = 'guest_checkout';
6767
$captchaModel = $this->_helper->getCaptcha($formId);
6868
$checkoutMethod = $this->_typeOnepage->getQuote()->getCheckoutMethod();
69-
if ($checkoutMethod == \Magento\Checkout\Model\Type\Onepage::METHOD_GUEST) {
70-
if ($captchaModel->isRequired()) {
71-
$controller = $observer->getControllerAction();
72-
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))
73-
) {
74-
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
75-
$result = ['error' => 1, 'message' => __('Incorrect CAPTCHA')];
76-
$controller->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
77-
}
69+
if ($checkoutMethod == \Magento\Checkout\Model\Type\Onepage::METHOD_GUEST
70+
&& $captchaModel->isRequired()
71+
) {
72+
$controller = $observer->getControllerAction();
73+
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
74+
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
75+
$result = ['error' => 1, 'message' => __('Incorrect CAPTCHA')];
76+
$controller->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
7877
}
7978
}
8079

app/code/Magento/Captcha/Observer/CheckRegisterCheckoutObserver.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,14 @@ public function execute(\Magento\Framework\Event\Observer $observer)
6666
$formId = 'register_during_checkout';
6767
$captchaModel = $this->_helper->getCaptcha($formId);
6868
$checkoutMethod = $this->_typeOnepage->getQuote()->getCheckoutMethod();
69-
if ($checkoutMethod == \Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER) {
70-
if ($captchaModel->isRequired()) {
71-
$controller = $observer->getControllerAction();
72-
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))
73-
) {
74-
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
75-
$result = ['error' => 1, 'message' => __('Incorrect CAPTCHA')];
76-
$controller->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
77-
}
69+
if ($checkoutMethod == \Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER
70+
&& $captchaModel->isRequired()
71+
) {
72+
$controller = $observer->getControllerAction();
73+
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
74+
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
75+
$result = ['error' => 1, 'message' => __('Incorrect CAPTCHA')];
76+
$controller->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
7877
}
7978
}
8079

app/code/Magento/Captcha/Observer/CheckUserForgotPasswordBackendObserver.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,17 @@ public function execute(\Magento\Framework\Event\Observer $observer)
6969
$controller = $observer->getControllerAction();
7070
$email = (string)$observer->getControllerAction()->getRequest()->getParam('email');
7171
$params = $observer->getControllerAction()->getRequest()->getParams();
72-
if (!empty($email) && !empty($params)) {
73-
if ($captchaModel->isRequired()) {
74-
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))
75-
) {
76-
$this->_session->setEmail((string)$controller->getRequest()->getPost('email'));
77-
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
78-
$this->messageManager->addError(__('Incorrect CAPTCHA'));
79-
$controller->getResponse()->setRedirect(
80-
$controller->getUrl('*/*/forgotpassword', ['_nosecret' => true])
81-
);
82-
}
83-
}
72+
if (!empty($email)
73+
&& !empty($params)
74+
&& $captchaModel->isRequired()
75+
&& !$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))
76+
) {
77+
$this->_session->setEmail((string)$controller->getRequest()->getPost('email'));
78+
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
79+
$this->messageManager->addError(__('Incorrect CAPTCHA'));
80+
$controller->getResponse()->setRedirect(
81+
$controller->getUrl('*/*/forgotpassword', ['_nosecret' => true])
82+
);
8483
}
8584

8685
return $this;

app/code/Magento/Captcha/Observer/CheckUserLoginBackendObserver.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ public function execute(\Magento\Framework\Event\Observer $observer)
5252
$formId = 'backend_login';
5353
$captchaModel = $this->_helper->getCaptcha($formId);
5454
$login = $observer->getEvent()->getUsername();
55-
if ($captchaModel->isRequired($login)) {
56-
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($this->_request, $formId))) {
57-
$captchaModel->logAttempt($login);
58-
throw new PluginAuthenticationException(__('Incorrect CAPTCHA.'));
59-
}
55+
if ($captchaModel->isRequired($login)
56+
&& !$captchaModel->isCorrect($this->captchaStringResolver->resolve($this->_request, $formId))
57+
) {
58+
$captchaModel->logAttempt($login);
59+
throw new PluginAuthenticationException(__('Incorrect CAPTCHA.'));
6060
}
6161
$captchaModel->logAttempt($login);
6262

app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function getElementHtml()
102102
*/
103103
public function getImages()
104104
{
105-
return $this->registry->registry('current_product')->getData('media_gallery') ?: null;
105+
return $this->getDataObject()->getData('media_gallery') ?: null;
106106
}
107107

108108
/**

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ public function execute()
9292
$attributeSet->setEntityTypeId($this->_entityTypeId)->load($setName, 'attribute_set_name');
9393
if ($attributeSet->getId()) {
9494
$setName = $this->_objectManager->get(\Magento\Framework\Escaper::class)->escapeHtml($setName);
95-
$this->messageManager->addError(
96-
__('A "%1" attribute set name already exists. Create a new name and try again.', $setName)
97-
);
95+
$this->messageManager->addErrorMessage(__('An attribute set named \'%1\' already exists.', $setName));
9896

9997
$layout = $this->layoutFactory->create();
10098
$layout->initMessages();

app/code/Magento/Catalog/Controller/Adminhtml/Product/MassDelete.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ public function execute()
6464
$this->productRepository->delete($product);
6565
$productDeleted++;
6666
}
67-
$this->messageManager->addSuccess(
68-
__('A total of %1 record(s) have been deleted.', $productDeleted)
69-
);
67+
68+
if ($productDeleted) {
69+
$this->messageManager->addSuccessMessage(
70+
__('A total of %1 record(s) have been deleted.', $productDeleted)
71+
);
72+
}
7073

7174
return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setPath('catalog/*/index');
7275
}

app/code/Magento/Newsletter/Block/Adminhtml/Template/Edit.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ public function getModel()
6767
*/
6868
protected function _prepareLayout()
6969
{
70-
// Load Wysiwyg on demand and Prepare layout
71-
// $block = $this->getLayout()->getBlock('head');
72-
// if ($this->_wysiwygConfig->isEnabled() && $block) {
73-
// $block->setCanLoadTinyMce(true);
74-
// }
75-
7670
$this->getToolbar()->addChild(
7771
'back_button',
7872
\Magento\Backend\Block\Widget\Button::class,

app/code/Magento/Review/Block/Adminhtml/Add/Form.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,6 @@ protected function _prepareForm()
142142

143143
$fieldset->addField('product_id', 'hidden', ['name' => 'product_id']);
144144

145-
/*$gridFieldset = $form->addFieldset('add_review_grid', array('legend' => __('Please select a product')));
146-
$gridFieldset->addField('products_grid', 'note', array(
147-
'text' => $this->getLayout()->createBlock(\Magento\Review\Block\Adminhtml\Product\Grid::class)->toHtml(),
148-
));*/
149-
150145
$form->setMethod('post');
151146
$form->setUseContainer(true);
152147
$form->setId('edit_form');

app/code/Magento/Sales/Model/Order/Creditmemo.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -582,13 +582,6 @@ public function getCommentsCollection($reload = false)
582582
{
583583
$collection = $this->_commentCollectionFactory->create()->setCreditmemoFilter($this->getId())
584584
->setCreatedAtOrder();
585-
//
586-
// $this->setComments($comments);
587-
// /**
588-
// * When credit memo created with adding comment,
589-
// * comments collection must be loaded before we added this comment.
590-
// */
591-
// $this->getComments()->load();
592585

593586
if ($this->getId()) {
594587
foreach ($collection as $comment) {

app/code/Magento/Sales/view/adminhtml/templates/order/totals.phtml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@
77
// @codingStandardsIgnoreFile
88

99
?>
10-
<?php /*$_source = $block->getSource(); ?>
11-
<?php $block->setPriceDataObject($_source) ?>
12-
<?php if ($_source): ?>
13-
<table width="100%">
14-
<?= $block->getChildHtml('main') ?>
15-
<?= $block->getChildHtml('footer') ?>
16-
</table>
17-
<?php endif;*/ ?>
1810
<table class="data-table admin__table-secondary order-subtotal-table">
1911
<?php $_totals = $block->getTotals('footer')?>
2012

app/code/Magento/User/Controller/Adminhtml/Auth.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,32 @@
77
namespace Magento\User\Controller\Adminhtml;
88

99
use Magento\Framework\Encryption\Helper\Security;
10+
use Magento\Backend\App\AbstractAction;
11+
use Magento\Backend\App\Action\Context;
12+
use Magento\User\Model\UserFactory;
13+
use Magento\Framework\Exception\LocalizedException;
1014

1115
/**
1216
* \Magento\User Auth controller
1317
*/
14-
abstract class Auth extends \Magento\Backend\App\AbstractAction
18+
abstract class Auth extends AbstractAction
1519
{
1620
/**
1721
* User model factory
1822
*
19-
* @var \Magento\User\Model\UserFactory
23+
* @var UserFactory
2024
*/
2125
protected $_userFactory;
2226

2327
/**
2428
* Construct
2529
*
26-
* @param \Magento\Backend\App\Action\Context $context
27-
* @param \Magento\User\Model\UserFactory $userFactory
30+
* @param Context $context
31+
* @param UserFactory $userFactory
2832
*/
2933
public function __construct(
30-
\Magento\Backend\App\Action\Context $context,
31-
\Magento\User\Model\UserFactory $userFactory
34+
Context $context,
35+
UserFactory $userFactory
3236
) {
3337
parent::__construct($context);
3438
$this->_userFactory = $userFactory;
@@ -40,7 +44,7 @@ public function __construct(
4044
* @param int $userId
4145
* @param string $resetPasswordToken
4246
* @return void
43-
* @throws \Magento\Framework\Exception\LocalizedException
47+
* @throws LocalizedException
4448
*/
4549
protected function _validateResetPasswordLinkToken($userId, $resetPasswordToken)
4650
{
@@ -50,22 +54,20 @@ protected function _validateResetPasswordLinkToken($userId, $resetPasswordToken)
5054
$resetPasswordToken
5155
) || empty($resetPasswordToken) || empty($userId) || $userId < 0
5256
) {
53-
throw new \Magento\Framework\Exception\LocalizedException(
54-
__('The password reset token is incorrect. Verify the token and try again.')
55-
);
57+
throw new LocalizedException(__('Please correct the password reset token.'));
5658
}
5759

5860
/** @var $user \Magento\User\Model\User */
5961
$user = $this->_userFactory->create()->load($userId);
6062
if (!$user->getId()) {
61-
throw new \Magento\Framework\Exception\LocalizedException(
63+
throw new LocalizedException(
6264
__('Please specify the correct account and try again.')
6365
);
6466
}
6567

6668
$userToken = $user->getRpToken();
6769
if (!Security::compareStrings($userToken, $resetPasswordToken) || $user->isResetPasswordLinkTokenExpired()) {
68-
throw new \Magento\Framework\Exception\LocalizedException(__('Your password reset link has expired.'));
70+
throw new LocalizedException(__('Your password reset link has expired.'));
6971
}
7072
}
7173

app/code/Magento/User/Controller/Adminhtml/Auth/Forgotpassword.php

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,54 @@
77
namespace Magento\User\Controller\Adminhtml\Auth;
88

99
use Magento\Security\Model\SecurityManager;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Backend\App\Action\Context;
12+
use Magento\User\Model\UserFactory;
13+
use Magento\User\Model\ResourceModel\User\CollectionFactory;
14+
use Magento\Framework\Validator\EmailAddress;
15+
use Magento\Security\Model\PasswordResetRequestEvent;
16+
use Magento\Framework\Exception\SecurityViolationException;
17+
use Magento\User\Controller\Adminhtml\Auth;
18+
use Magento\Backend\Helper\Data;
1019

11-
class Forgotpassword extends \Magento\User\Controller\Adminhtml\Auth
20+
class Forgotpassword extends Auth
1221
{
1322
/**
1423
* @var SecurityManager
1524
*/
1625
protected $securityManager;
1726

1827
/**
19-
* @param \Magento\Backend\App\Action\Context $context
20-
* @param \Magento\User\Model\UserFactory $userFactory
21-
* @param \Magento\Security\Model\SecurityManager $securityManager
28+
* User model factory
29+
*
30+
* @var CollectionFactory
31+
*/
32+
private $userCollectionFactory;
33+
34+
/**
35+
* @var Data
36+
*/
37+
private $backendDataHelper;
38+
39+
/**
40+
* @param Context $context
41+
* @param UserFactory $userFactory
42+
* @param SecurityManager $securityManager
43+
* @param CollectionFactory $userCollectionFactory
2244
*/
2345
public function __construct(
24-
\Magento\Backend\App\Action\Context $context,
25-
\Magento\User\Model\UserFactory $userFactory,
26-
\Magento\Security\Model\SecurityManager $securityManager
46+
Context $context,
47+
UserFactory $userFactory,
48+
SecurityManager $securityManager,
49+
CollectionFactory $userCollectionFactory = null,
50+
Data $backendDataHelper = null
2751
) {
2852
parent::__construct($context, $userFactory);
2953
$this->securityManager = $securityManager;
54+
$this->userCollectionFactory = $userCollectionFactory ?:
55+
ObjectManager::getInstance()->get(CollectionFactory::class);
56+
$this->backendDataHelper = $backendDataHelper ?:
57+
ObjectManager::getInstance()->get(Data::class);
3058
}
3159

3260
/**
@@ -44,18 +72,18 @@ public function execute()
4472
$resultRedirect = $this->resultRedirectFactory->create();
4573
if (!empty($email) && !empty($params)) {
4674
// Validate received data to be an email address
47-
if (\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) {
75+
if (\Zend_Validate::is($email, EmailAddress::class)) {
4876
try {
4977
$this->securityManager->performSecurityCheck(
50-
\Magento\Security\Model\PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST,
78+
PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST,
5179
$email
5280
);
53-
} catch (\Magento\Framework\Exception\SecurityViolationException $exception) {
81+
} catch (SecurityViolationException $exception) {
5482
$this->messageManager->addErrorMessage($exception->getMessage());
5583
return $resultRedirect->setPath('admin');
5684
}
57-
$collection = $this->_objectManager->get(\Magento\User\Model\ResourceModel\User\Collection::class);
5885
/** @var $collection \Magento\User\Model\ResourceModel\User\Collection */
86+
$collection = $this->userCollectionFactory->create();
5987
$collection->addFieldToFilter('email', $email);
6088
$collection->load(false);
6189

@@ -65,9 +93,7 @@ public function execute()
6593
/** @var \Magento\User\Model\User $user */
6694
$user = $this->_userFactory->create()->load($item->getId());
6795
if ($user->getId()) {
68-
$newPassResetToken = $this->_objectManager->get(
69-
\Magento\User\Helper\Data::class
70-
)->generateResetPasswordLinkToken();
96+
$newPassResetToken = $this->backendDataHelper->generateResetPasswordLinkToken();
7197
$user->changeResetPasswordLinkToken($newPassResetToken);
7298
$user->save();
7399
$user->sendPasswordResetConfirmationEmail();
@@ -86,7 +112,7 @@ public function execute()
86112
$this->messageManager->addSuccess(__('We\'ll email you a link to reset your password.'));
87113
// @codingStandardsIgnoreEnd
88114
$this->getResponse()->setRedirect(
89-
$this->_objectManager->get(\Magento\Backend\Helper\Data::class)->getHomePageUrl()
115+
$this->backendDataHelper->getHomePageUrl()
90116
);
91117
return;
92118
} else {

0 commit comments

Comments
 (0)