Skip to content

Commit efd8482

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into MAGETWO-73342
2 parents feb7d25 + 6f162dd commit efd8482

File tree

55 files changed

+1055
-1044
lines changed

Some content is hidden

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

55 files changed

+1055
-1044
lines changed

app/code/Magento/Braintree/view/adminhtml/web/js/braintree.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ define([
2424
scriptLoaded: false,
2525
braintree: null,
2626
selectedCardType: null,
27+
checkout: null,
2728
imports: {
2829
onActiveChange: 'active'
2930
}
@@ -147,14 +148,21 @@ define([
147148

148149
this.disableEventListeners();
149150

151+
if (self.checkout) {
152+
self.checkout.teardown(function () {
153+
self.checkout = null;
154+
});
155+
}
156+
150157
self.braintree.setup(self.clientToken, 'custom', {
151158
id: self.selector,
152159
hostedFields: self.getHostedFields(),
153160

154161
/**
155162
* Triggered when sdk was loaded
156163
*/
157-
onReady: function () {
164+
onReady: function (checkout) {
165+
self.checkout = checkout;
158166
$('body').trigger('processStop');
159167
self.enableEventListeners();
160168
},

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/Test/Unit/Ui/DataProvider/Product/Form/Modifier/WebsitesTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,11 @@ protected function setUp()
9090
->disableOriginalConstructor()
9191
->getMock();
9292
$this->websiteRepositoryMock = $this->getMockBuilder(\Magento\Store\Api\WebsiteRepositoryInterface::class)
93-
->setMethods(['getList', 'getDefault'])
93+
->setMethods(['getDefault'])
9494
->getMockForAbstractClass();
9595
$this->websiteRepositoryMock->expects($this->any())
9696
->method('getDefault')
9797
->willReturn($this->websiteMock);
98-
$this->websiteRepositoryMock->expects($this->any())
99-
->method('getList')
100-
->willReturn([$this->websiteMock, $this->secondWebsiteMock]);
10198
$this->groupRepositoryMock = $this->getMockBuilder(\Magento\Store\Api\GroupRepositoryInterface::class)
10299
->setMethods(['getList'])
103100
->getMockForAbstractClass();
@@ -111,8 +108,10 @@ protected function setUp()
111108
->method('getWebsiteIds')
112109
->willReturn($this->assignedWebsites);
113110
$this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
114-
->setMethods(['isSingleStoreMode'])
111+
->setMethods(['isSingleStoreMode', 'getWebsites'])
115112
->getMockForAbstractClass();
113+
$this->storeManagerMock->method('getWebsites')
114+
->willReturn([$this->websiteMock, $this->secondWebsiteMock]);
116115
$this->storeManagerMock->expects($this->any())
117116
->method('isSingleStoreMode')
118117
->willReturn(false);

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Websites.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,11 @@ protected function getFieldsForFieldset()
175175
$label = __('Websites');
176176

177177
$defaultWebsiteId = $this->websiteRepository->getDefault()->getId();
178+
$isOnlyOneWebsiteAvailable = count($websitesList) === 1;
178179
foreach ($websitesList as $website) {
179180
$isChecked = in_array($website['id'], $websiteIds)
180-
|| ($defaultWebsiteId == $website['id'] && $isNewProduct);
181+
|| ($defaultWebsiteId == $website['id'] && $isNewProduct)
182+
|| $isOnlyOneWebsiteAvailable;
181183
$children[$website['id']] = [
182184
'arguments' => [
183185
'data' => [
@@ -397,8 +399,9 @@ protected function getWebsitesList()
397399
$this->websitesList = [];
398400
$groupList = $this->groupRepository->getList();
399401
$storesList = $this->storeRepository->getList();
402+
$websiteList = $this->storeManager->getWebsites(true);
400403

401-
foreach ($this->websiteRepository->getList() as $website) {
404+
foreach ($websiteList as $website) {
402405
$websiteId = $website->getId();
403406
if (!$websiteId) {
404407
continue;

0 commit comments

Comments
 (0)