Skip to content

Commit 7289b10

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into PR_Branch
2 parents 048d89d + f53c16c commit 7289b10

File tree

51 files changed

+1130
-513
lines changed

Some content is hidden

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

51 files changed

+1130
-513
lines changed

app/code/Magento/Authorizenet/Controller/Directpost/Payment/Redirect.php

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,12 @@
88

99
use Magento\Framework\App\ObjectManager;
1010
use Magento\Payment\Block\Transparent\Iframe;
11-
use Magento\Framework\Escaper;
1211

1312
/**
1413
* Class Redirect
1514
*/
1615
class Redirect extends \Magento\Authorizenet\Controller\Directpost\Payment
1716
{
18-
/**
19-
* @var Escaper
20-
*/
21-
private $escaper;
22-
2317
/**
2418
* Retrieve params and put javascript into iframe
2519
*
@@ -29,7 +23,7 @@ public function execute()
2923
{
3024
$helper = $this->dataFactory->create('frontend');
3125

32-
$redirectParams = $this->filterData($this->getRequest()->getParams());
26+
$redirectParams = $this->getRequest()->getParams();
3327
$params = [];
3428
if (!empty($redirectParams['success'])
3529
&& isset($redirectParams['x_invoice_num'])
@@ -38,9 +32,11 @@ public function execute()
3832
$this->_getDirectPostSession()->unsetData('quote_id');
3933
$params['redirect_parent'] = $helper->getSuccessOrderUrl([]);
4034
}
35+
4136
if (!empty($redirectParams['error_msg'])) {
4237
$cancelOrder = empty($redirectParams['x_invoice_num']);
4338
$this->_returnCustomerQuote($cancelOrder, $redirectParams['error_msg']);
39+
$params['error_msg'] = $redirectParams['error_msg'];
4440
}
4541

4642
if (isset($redirectParams['controller_action_name'])
@@ -50,34 +46,8 @@ public function execute()
5046
unset($params['redirect_parent']);
5147
}
5248

53-
$this->_coreRegistry->register(Iframe::REGISTRY_KEY, array_merge($params, $redirectParams));
49+
$this->_coreRegistry->register(Iframe::REGISTRY_KEY, $params);
5450
$this->_view->addPageLayoutHandles();
5551
$this->_view->loadLayout(false)->renderLayout();
5652
}
57-
58-
/**
59-
* Escape xss in request data
60-
* @param array $data
61-
* @return array
62-
*/
63-
private function filterData(array $data)
64-
{
65-
$self = $this;
66-
array_walk($data, function (&$item) use ($self) {
67-
$item = $self->getEscaper()->escapeXssInUrl($item);
68-
});
69-
return $data;
70-
}
71-
72-
/**
73-
* Get Escaper instance
74-
* @return Escaper
75-
*/
76-
private function getEscaper()
77-
{
78-
if (!$this->escaper) {
79-
$this->escaper = ObjectManager::getInstance()->get(Escaper::class);
80-
}
81-
return $this->escaper;
82-
}
8353
}

app/code/Magento/Authorizenet/Test/Unit/Controller/Directpost/Payment/RedirectTest.php

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Magento\Authorizenet\Controller\Directpost\Payment\Redirect;
99
use Magento\Framework\App\RequestInterface;
1010
use Magento\Framework\App\ViewInterface;
11-
use Magento\Framework\Escaper;
1211
use Magento\Framework\Registry;
1312
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1413
use Magento\Payment\Block\Transparent\Iframe;
@@ -34,11 +33,6 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
3433
*/
3534
private $coreRegistry;
3635

37-
/**
38-
* @var Escaper|MockObject
39-
*/
40-
private $escaper;
41-
4236
/**
4337
* @var Redirect
4438
*/
@@ -57,21 +51,11 @@ protected function setUp()
5751
->setMethods(['register'])
5852
->getMock();
5953

60-
$this->escaper = static::getMockBuilder(Escaper::class)
61-
->disableOriginalConstructor()
62-
->setMethods(['escapeXssInUrl'])
63-
->getMock();
64-
6554
$this->controller = $objectManager->getObject(Redirect::class, [
6655
'request' => $this->request,
6756
'view' => $this->view,
6857
'coreRegistry' => $this->coreRegistry
6958
]);
70-
71-
$refClass = new \ReflectionClass(Redirect::class);
72-
$refProperty = $refClass->getProperty('escaper');
73-
$refProperty->setAccessible(true);
74-
$refProperty->setValue($this->controller, $this->escaper);
7559
}
7660

7761
/**
@@ -87,14 +71,9 @@ public function testExecute()
8771
->method('getParams')
8872
->willReturn($params);
8973

90-
$this->escaper->expects(static::once())
91-
->method('escapeXssInUrl')
92-
->with($url)
93-
->willReturn($url);
94-
9574
$this->coreRegistry->expects(static::once())
9675
->method('register')
97-
->with(Iframe::REGISTRY_KEY, $params);
76+
->with(Iframe::REGISTRY_KEY, []);
9877

9978
$this->view->expects(static::once())
10079
->method('addPageLayoutHandles');

app/code/Magento/Braintree/Controller/Payment/GetNonce.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
use Magento\Framework\Controller\ResultInterface;
1313
use Magento\Framework\Session\SessionManagerInterface;
1414
use Magento\Framework\Webapi\Exception;
15-
use Psr\Log\LoggerInterface;
16-
use Magento\Vault\Model\Ui\TokenUiComponentProviderInterface;
17-
use Magento\CheckoutAgreements;
1815
use Magento\Theme;
16+
use Psr\Log\LoggerInterface;
1917

2018
/**
2119
* Class GetNonce

app/code/Magento/Braintree/composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
"magento/module-catalog": "*",
1717
"magento/module-quote": "*",
1818
"magento/module-paypal": "*",
19-
"magento/module-checkout-agreements": "*",
2019
"magento/module-theme": "*",
2120
"braintree/braintree_php": "3.7.0"
2221
},
22+
"suggest": {
23+
"magento/module-checkout-agreements": "100.0.*"
24+
},
2325
"type": "magento2-module",
2426
"version": "100.0.2",
2527
"license": [

app/code/Magento/Braintree/etc/module.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
<module name="Magento_Catalog"/>
1616
<module name="Magento_Quote"/>
1717
<module name="Magento_Paypal"/>
18-
<module name="Magento_CheckoutAgreements"/>
1918
<module name="Magento_Theme"/>
2019
</sequence>
2120
</module>

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ define([
1010
'Magento_Checkout/js/view/payment/default',
1111
'Magento_Braintree/js/view/payment/adapter',
1212
'Magento_Checkout/js/model/quote',
13-
'Magento_Checkout/js/model/full-screen-loader'
14-
], function ($, _, Component, Braintree, quote, fullScreenLoader) {
13+
'Magento_Checkout/js/model/full-screen-loader',
14+
'Magento_Checkout/js/model/payment/additional-validators'
15+
], function ($, _, Component, Braintree, quote, fullScreenLoader, additionalValidators) {
1516
'use strict';
1617

1718
var checkout;
@@ -173,7 +174,9 @@ define([
173174
* Triggers when customer click "Continue to PayPal" button
174175
*/
175176
payWithPayPal: function () {
176-
checkout.paypal.initAuthFlow();
177+
if (additionalValidators.validate()) {
178+
checkout.paypal.initAuthFlow();
179+
}
177180
},
178181

179182
/**

app/code/Magento/Braintree/view/frontend/web/template/payment/form.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@
131131
</fieldset>
132132
<input type="submit" id="braintree_submit" style="display:none" />
133133
</form>
134+
<div class="checkout-agreements-block">
135+
<!-- ko foreach: $parent.getRegion('before-place-order') -->
136+
<!-- ko template: getTemplate() --><!-- /ko -->
137+
<!--/ko-->
138+
</div>
134139
<div class="actions-toolbar">
135140
<div class="primary">
136141
<button class="action primary checkout"

app/code/Magento/Bundle/Model/LinkManagement.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ protected function mapProductLinkToSelectionModel(
204204

205205
/**
206206
* {@inheritdoc}
207+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
207208
*/
208209
public function addChild(
209210
\Magento\Catalog\Api\Data\ProductInterface $product,
@@ -238,19 +239,25 @@ public function addChild(
238239
if ($linkProductModel->isComposite()) {
239240
throw new InputException(__('Bundle product could not contain another composite product'));
240241
}
242+
241243
if ($selections) {
242244
foreach ($selections as $selection) {
243245
if ($selection['option_id'] == $optionId &&
244246
$selection['product_id'] == $linkProductModel->getEntityId()) {
245-
throw new CouldNotSaveException(
246-
__(
247-
'Child with specified sku: "%1" already assigned to product: "%2"',
248-
[$linkedProduct->getSku(), $product->getSku()]
249-
)
250-
);
247+
if (!$product->getCopyFromView()) {
248+
throw new CouldNotSaveException(
249+
__(
250+
'Child with specified sku: "%1" already assigned to product: "%2"',
251+
[$linkedProduct->getSku(), $product->getSku()]
252+
)
253+
);
254+
} else {
255+
return $this->bundleSelection->create()->load($linkProductModel->getEntityId());
256+
}
251257
}
252258
}
253259
}
260+
254261
$selectionModel = $this->bundleSelection->create();
255262
$selectionModel = $this->mapProductLinkToSelectionModel(
256263
$selectionModel,

app/code/Magento/Bundle/Model/OptionRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function save(
189189
$option->setStoreId($product->getStoreId());
190190
$option->setParentId($product->getData($metadata->getLinkField()));
191191
$linksToAdd = [];
192-
$option->setDefaultTitle($option->getTitle());
192+
$option->setDefaultTitle($option->getDefaultTitle() ?: $option->getTitle());
193193
if (is_array($option->getProductLinks())) {
194194
$linksToAdd = $option->getProductLinks();
195195
}

app/code/Magento/Bundle/Model/Product/OptionList.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public function getItems(\Magento\Catalog\Api\Data\ProductInterface $product)
7575
);
7676
$optionDataObject->setOptionId($option->getOptionId())
7777
->setTitle($option->getTitle() === null ? $option->getDefaultTitle() : $option->getTitle())
78+
->setDefaultTitle($option->getDefaultTitle())
7879
->setSku($product->getSku())
7980
->setProductLinks($productLinks);
8081
$optionList[] = $optionDataObject;

0 commit comments

Comments
 (0)