Skip to content

Commit e89e9bf

Browse files
author
Stanislav Idolov
authored
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #17217: [Backport] Broken Responsive Layout on Top page (by @mage2pratik) - #17203: [Backport] Refactored multiples conditions which could be grouped in a single on� (by @mage2pratik) - #17246: [Backport] FIXED: FTP user and password strings urldecoded (by @mage2pratik) - #17236: [Backport] Fixed invalid knockoutjs data binding for Braintree PayPal (by @tiagosampaio) - #16594: Fix broken commit in #15040 that accidentally reverted previous changes. (by @gwharton) - #17122: Added missing exception cause for better error handling (by @woutersamaey) - #17153: Set proper text-aligh for the <th> element of the Subtotal column in the Creditmemo email (by @TomashKhamlai) - #17127: Allow 3rd party modules to perform actions after totals calculation (by @navarr) - #16505: admin checkout agreement controllers refactor (by @AnshuMishra17) - #16000: Don't force enable "Use system value" checkboxes (by @likemusic) Fixed GitHub Issues: - #15009: [2.2.4] Gallery theme variables being ignored (reported by @gwharton) has been fixed in #16594 by @gwharton in 2.2-develop branch Related commits: 1. a012c45 - #16580: Product gallery caption issue (reported by @Karlasa) has been fixed in #16594 by @gwharton in 2.2-develop branch Related commits: 1. a012c45
2 parents 3615110 + 1aab3fe commit e89e9bf

File tree

17 files changed

+181
-94
lines changed

17 files changed

+181
-94
lines changed

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/view/frontend/templates/product/view/gallery.phtml

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,11 @@
4747
"data": <?= /* @escapeNotVerified */ $block->getGalleryImagesJson() ?>,
4848
"options": {
4949
"nav": "<?= /* @escapeNotVerified */ $block->getVar("gallery/nav") ?>",
50-
<?php if (($block->getVar("gallery/loop"))): ?>
51-
"loop": <?= /* @escapeNotVerified */ $block->getVar("gallery/loop") ?>,
52-
<?php endif; ?>
53-
<?php if (($block->getVar("gallery/keyboard"))): ?>
54-
"keyboard": <?= /* @escapeNotVerified */ $block->getVar("gallery/keyboard") ?>,
55-
<?php endif; ?>
56-
<?php if (($block->getVar("gallery/arrows"))): ?>
57-
"arrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/arrows") ?>,
58-
<?php endif; ?>
59-
<?php if (($block->getVar("gallery/allowfullscreen"))): ?>
60-
"allowfullscreen": <?= /* @escapeNotVerified */ $block->getVar("gallery/allowfullscreen") ?>,
61-
<?php endif; ?>
62-
<?php if (($block->getVar("gallery/caption"))): ?>
63-
"showCaption": <?= /* @escapeNotVerified */ $block->getVar("gallery/caption") ?>,
64-
<?php endif; ?>
50+
"loop": <?= /* @escapeNotVerified */ $block->getVar("gallery/loop") ? 'true' : 'false' ?>,
51+
"keyboard": <?= /* @escapeNotVerified */ $block->getVar("gallery/keyboard") ? 'true' : 'false' ?>,
52+
"arrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/arrows") ? 'true' : 'false' ?>,
53+
"allowfullscreen": <?= /* @escapeNotVerified */ $block->getVar("gallery/allowfullscreen") ? 'true' : 'false' ?>,
54+
"showCaption": <?= /* @escapeNotVerified */ $block->getVar("gallery/caption") ? 'true' : 'false' ?>,
6555
"width": "<?= /* @escapeNotVerified */ $block->getImageAttribute('product_page_image_medium', 'width') ?>",
6656
"thumbwidth": "<?= /* @escapeNotVerified */ $block->getImageAttribute('product_page_image_small', 'width') ?>",
6757
<?php if ($block->getImageAttribute('product_page_image_small', 'height') || $block->getImageAttribute('product_page_image_small', 'width')): ?>
@@ -79,28 +69,18 @@
7969
"transitionduration": <?= /* @escapeNotVerified */ $block->getVar("gallery/transition/duration") ?>,
8070
<?php endif; ?>
8171
"transition": "<?= /* @escapeNotVerified */ $block->getVar("gallery/transition/effect") ?>",
82-
<?php if (($block->getVar("gallery/navarrows"))): ?>
83-
"navarrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/navarrows") ?>,
84-
<?php endif; ?>
72+
"navarrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/navarrows") ? 'true' : 'false' ?>,
8573
"navtype": "<?= /* @escapeNotVerified */ $block->getVar("gallery/navtype") ?>",
8674
"navdir": "<?= /* @escapeNotVerified */ $block->getVar("gallery/navdir") ?>"
8775
},
8876
"fullscreen": {
8977
"nav": "<?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/nav") ?>",
90-
<?php if ($block->getVar("gallery/fullscreen/loop")): ?>
91-
"loop": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/loop") ?>,
92-
<?php endif; ?>
78+
"loop": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/loop") ? 'true' : 'false' ?>,
9379
"navdir": "<?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/navdir") ?>",
94-
<?php if ($block->getVar("gallery/transition/navarrows")): ?>
95-
"navarrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/navarrows") ?>,
96-
<?php endif; ?>
80+
"navarrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/navarrows") ? 'true' : 'false' ?>,
9781
"navtype": "<?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/navtype") ?>",
98-
<?php if ($block->getVar("gallery/fullscreen/arrows")): ?>
99-
"arrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/arrows") ?>,
100-
<?php endif; ?>
101-
<?php if ($block->getVar("gallery/fullscreen/caption")): ?>
102-
"showCaption": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/caption") ?>,
103-
<?php endif; ?>
82+
"arrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/arrows") ? 'true' : 'false' ?>,
83+
"showCaption": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/caption") ? 'true' : 'false' ?>,
10484
<?php if ($block->getVar("gallery/fullscreen/transition/duration")): ?>
10585
"transitionduration": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/transition/duration") ?>,
10686
<?php endif; ?>

app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ define([
3838
payload.addressInformation['shipping_carrier_code'] = quote.shippingMethod()['carrier_code'];
3939
}
4040

41-
storage.post(
41+
return storage.post(
4242
serviceUrl, JSON.stringify(payload), false
4343
).done(function (result) {
4444
var data = {
@@ -96,7 +96,7 @@ define([
9696
) {
9797
quote.setTotals(cartCache.get('totals'));
9898
} else {
99-
loadFromServer(address);
99+
return loadFromServer(address);
100100
}
101101
}
102102
};

app/code/Magento/CheckoutAgreements/Controller/Adminhtml/Agreement.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
*/
66
namespace Magento\CheckoutAgreements\Controller\Adminhtml;
77

8-
abstract class Agreement extends \Magento\Backend\App\Action
8+
use Magento\Backend\App\Action;
9+
use Magento\Backend\App\Action\Context;
10+
use Magento\Framework\Registry;
11+
12+
abstract class Agreement extends Action
913
{
1014
/**
1115
* Authorization level of a basic admin session
@@ -22,12 +26,14 @@ abstract class Agreement extends \Magento\Backend\App\Action
2226
protected $_coreRegistry = null;
2327

2428
/**
25-
* @param \Magento\Backend\App\Action\Context $context
26-
* @param \Magento\Framework\Registry $coreRegistry
29+
* @param Context $context
30+
* @param Registry $coreRegistry
2731
* @codeCoverageIgnore
2832
*/
29-
public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry)
30-
{
33+
public function __construct(
34+
Context $context,
35+
Registry $coreRegistry
36+
) {
3137
$this->_coreRegistry = $coreRegistry;
3238
parent::__construct($context);
3339
}

app/code/Magento/CheckoutAgreements/Controller/Adminhtml/Agreement/Delete.php

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,53 @@
66
*/
77
namespace Magento\CheckoutAgreements\Controller\Adminhtml\Agreement;
88

9-
class Delete extends \Magento\CheckoutAgreements\Controller\Adminhtml\Agreement
9+
use Magento\CheckoutAgreements\Api\CheckoutAgreementsRepositoryInterface;
10+
use Magento\CheckoutAgreements\Controller\Adminhtml\Agreement;
11+
use Magento\Backend\App\Action\Context;
12+
use Magento\Framework\Registry;
13+
use Magento\Framework\App\ObjectManager;
14+
use Magento\Framework\Exception\LocalizedException;
15+
16+
class Delete extends Agreement
1017
{
18+
/**
19+
* @var CheckoutAgreementsRepositoryInterface
20+
*/
21+
private $agreementRepository;
22+
23+
/**
24+
* @param Context $context
25+
* @param Registry $coreRegistry
26+
* @param CheckoutAgreementsRepositoryInterface $agreementRepository
27+
*/
28+
public function __construct(
29+
Context $context,
30+
Registry $coreRegistry,
31+
CheckoutAgreementsRepositoryInterface $agreementRepository = null
32+
) {
33+
$this->agreementRepository = $agreementRepository ?:
34+
ObjectManager::getInstance()->get(CheckoutAgreementsRepositoryInterface::class);
35+
parent::__construct($context, $coreRegistry);
36+
}
1137
/**
1238
* @return void
1339
*/
1440
public function execute()
1541
{
1642
$id = (int)$this->getRequest()->getParam('id');
17-
$model = $this->_objectManager->get(\Magento\CheckoutAgreements\Model\Agreement::class)->load($id);
18-
if (!$model->getId()) {
43+
$agreement = $this->agreementRepository->get($id);
44+
if (!$agreement->getAgreementId()) {
1945
$this->messageManager->addError(__('This condition no longer exists.'));
2046
$this->_redirect('checkout/*/');
2147
return;
2248
}
2349

2450
try {
25-
$model->delete();
51+
$this->agreementRepository->delete($agreement);
2652
$this->messageManager->addSuccess(__('You deleted the condition.'));
2753
$this->_redirect('checkout/*/');
2854
return;
29-
} catch (\Magento\Framework\Exception\LocalizedException $e) {
55+
} catch (LocalizedException $e) {
3056
$this->messageManager->addError($e->getMessage());
3157
} catch (\Exception $e) {
3258
$this->messageManager->addError(__('Something went wrong while deleting this condition.'));

app/code/Magento/CheckoutAgreements/Controller/Adminhtml/Agreement/Edit.php

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,42 @@
66
*/
77
namespace Magento\CheckoutAgreements\Controller\Adminhtml\Agreement;
88

9-
class Edit extends \Magento\CheckoutAgreements\Controller\Adminhtml\Agreement
9+
use Magento\CheckoutAgreements\Controller\Adminhtml\Agreement;
10+
use Magento\CheckoutAgreements\Model\AgreementFactory;
11+
use Magento\Backend\App\Action\Context;
12+
use Magento\Framework\Registry;
13+
use Magento\Framework\App\ObjectManager;
14+
use Magento\CheckoutAgreements\Block\Adminhtml\Agreement\Edit as BlockEdit;
15+
16+
class Edit extends Agreement
1017
{
18+
/**
19+
* @var AgreementFactory
20+
*/
21+
private $agreementFactory;
22+
23+
/**
24+
* @param Context $context
25+
* @param Registry $coreRegistry
26+
* @param AgreementFactory $agreementFactory
27+
*/
28+
public function __construct(
29+
Context $context,
30+
Registry $coreRegistry,
31+
AgreementFactory $agreementFactory = null
32+
) {
33+
$this->agreementFactory = $agreementFactory ?:
34+
ObjectManager::getInstance()->get(AgreementFactory::class);
35+
parent::__construct($context, $coreRegistry);
36+
}
1137
/**
1238
* @return void
1339
* @SuppressWarnings(PHPMD.NPathComplexity)
1440
*/
1541
public function execute()
1642
{
1743
$id = $this->getRequest()->getParam('id');
18-
$agreementModel = $this->_objectManager->create(\Magento\CheckoutAgreements\Model\Agreement::class);
44+
$agreementModel = $this->agreementFactory->create();
1945

2046
if ($id) {
2147
$agreementModel->load($id);
@@ -26,7 +52,7 @@ public function execute()
2652
}
2753
}
2854

29-
$data = $this->_objectManager->get(\Magento\Backend\Model\Session::class)->getAgreementData(true);
55+
$data = $this->_session->getAgreementData(true);
3056
if (!empty($data)) {
3157
$agreementModel->setData($data);
3258
}
@@ -38,7 +64,7 @@ public function execute()
3864
$id ? __('Edit Condition') : __('New Condition')
3965
)->_addContent(
4066
$this->_view->getLayout()->createBlock(
41-
\Magento\CheckoutAgreements\Block\Adminhtml\Agreement\Edit::class
67+
BlockEdit::class
4268
)->setData(
4369
'action',
4470
$this->getUrl('checkout/*/save')

app/code/Magento/CheckoutAgreements/Controller/Adminhtml/Agreement/Save.php

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,47 @@
66
*/
77
namespace Magento\CheckoutAgreements\Controller\Adminhtml\Agreement;
88

9-
class Save extends \Magento\CheckoutAgreements\Controller\Adminhtml\Agreement
9+
use Magento\CheckoutAgreements\Controller\Adminhtml\Agreement;
10+
use Magento\CheckoutAgreements\Model\AgreementFactory;
11+
use Magento\Backend\App\Action\Context;
12+
use Magento\Framework\Registry;
13+
use Magento\Framework\App\ObjectManager;
14+
use Magento\Framework\DataObject;
15+
use Magento\Framework\Exception\LocalizedException;
16+
17+
class Save extends Agreement
1018
{
19+
/**
20+
* @var AgreementFactory
21+
*/
22+
private $agreementFactory;
23+
24+
/**
25+
* @param Context $context
26+
* @param Registry $coreRegistry
27+
* @param AgreementFactory $agreementFactory
28+
*/
29+
public function __construct(
30+
Context $context,
31+
Registry $coreRegistry,
32+
AgreementFactory $agreementFactory = null
33+
) {
34+
$this->agreementFactory = $agreementFactory ?:
35+
ObjectManager::getInstance()->get(AgreementFactory::class);
36+
parent::__construct($context, $coreRegistry);
37+
}
1138
/**
1239
* @return void
1340
*/
1441
public function execute()
1542
{
1643
$postData = $this->getRequest()->getPostValue();
1744
if ($postData) {
18-
$model = $this->_objectManager->get(\Magento\CheckoutAgreements\Model\Agreement::class);
45+
$model = $this->agreementFactory->create();
1946
$model->setData($postData);
2047

2148
try {
22-
$validationResult = $model->validateData(new \Magento\Framework\DataObject($postData));
49+
$validationResult = $model->validateData(new DataObject($postData));
2350
if ($validationResult !== true) {
2451
foreach ($validationResult as $message) {
2552
$this->messageManager->addError($message);
@@ -30,13 +57,13 @@ public function execute()
3057
$this->_redirect('checkout/*/');
3158
return;
3259
}
33-
} catch (\Magento\Framework\Exception\LocalizedException $e) {
60+
} catch (LocalizedException $e) {
3461
$this->messageManager->addError($e->getMessage());
3562
} catch (\Exception $e) {
3663
$this->messageManager->addError(__('Something went wrong while saving this condition.'));
3764
}
3865

39-
$this->_objectManager->get(\Magento\Backend\Model\Session::class)->setAgreementData($postData);
66+
$this->_session->setAgreementData($postData);
4067
$this->getResponse()->setRedirect($this->_redirect->getRedirectUrl($this->getUrl('*')));
4168
}
4269
}

0 commit comments

Comments
 (0)