Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 4c71dc1

Browse files
authored
Merge pull request #20 from magento/2.3-develop
Latest 2.3 develop
2 parents 29645bd + c268006 commit 4c71dc1

File tree

310 files changed

+5553
-2281
lines changed

Some content is hidden

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

310 files changed

+5553
-2281
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ Tests:
19771977
* [#686](https://github.com/magento/magento2/issues/686) -- Product save validation errors in the admin don't hide the overlay
19781978
* [#702](https://github.com/magento/magento2/issues/702) -- Base table or view not found
19791979
* [#652](https://github.com/magento/magento2/issues/652) -- Multishipping checkout not to change the Billing address js issue
1980-
* [#648](https://github.com/magento/magento2/issues/648) -- An equal (=) sign in the hash of the product page to to break the tabs functionality
1980+
* [#648](https://github.com/magento/magento2/issues/648) -- An equal (=) sign in the hash of the product page to break the tabs functionality
19811981
* Service Contracts:
19821982
* Refactored usage of new API of the Customer module
19831983
* Implemented Service Contracts for the Sales module

app/code/Magento/Backend/App/AbstractAction.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,6 @@ private function _moveBlockToContainer(\Magento\Framework\View\Element\AbstractB
205205
*/
206206
public function dispatch(\Magento\Framework\App\RequestInterface $request)
207207
{
208-
if (!$this->_processUrlKeys()) {
209-
return parent::dispatch($request);
210-
}
211-
212208
if ($request->isDispatched() && $request->getActionName() !== 'denied' && !$this->_isAllowed()) {
213209
$this->_response->setStatusHeader(403, '1.1', 'Forbidden');
214210
if (!$this->_auth->isLoggedIn()) {
@@ -252,6 +248,9 @@ protected function _isUrlChecked()
252248
* Check url keys. If non valid - redirect
253249
*
254250
* @return bool
251+
*
252+
* @see \Magento\Backend\App\Request\BackendValidator for default
253+
* request validation.
255254
*/
256255
public function _processUrlKeys()
257256
{
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Backend\App\Request;
10+
11+
use Magento\Backend\App\AbstractAction;
12+
use Magento\Framework\App\ActionInterface;
13+
use Magento\Framework\App\CsrfAwareActionInterface;
14+
use Magento\Framework\App\Request\InvalidRequestException;
15+
use Magento\Framework\App\Request\ValidatorInterface;
16+
use Magento\Framework\App\RequestInterface;
17+
use Magento\Backend\Model\Auth;
18+
use Magento\Framework\App\Request\Http as HttpRequest;
19+
use Magento\Framework\Controller\Result\RawFactory;
20+
use Magento\Framework\Controller\Result\Raw as RawResult;
21+
use Magento\Framework\Controller\Result\RedirectFactory;
22+
use Magento\Framework\Data\Form\FormKey\Validator as FormKeyValidator;
23+
use Magento\Backend\Model\UrlInterface as BackendUrl;
24+
use Magento\Framework\Phrase;
25+
26+
/**
27+
* Do backend validations.
28+
*
29+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
30+
*/
31+
class BackendValidator implements ValidatorInterface
32+
{
33+
/**
34+
* @var Auth
35+
*/
36+
private $auth;
37+
38+
/**
39+
* @var FormKeyValidator
40+
*/
41+
private $formKeyValidator;
42+
43+
/**
44+
* @var BackendUrl
45+
*/
46+
private $backendUrl;
47+
48+
/**
49+
* @var RedirectFactory
50+
*/
51+
private $redirectFactory;
52+
53+
/**
54+
* @var RawFactory
55+
*/
56+
private $rawResultFactory;
57+
58+
/**
59+
* @param Auth $auth
60+
* @param FormKeyValidator $formKeyValidator
61+
* @param BackendUrl $backendUrl
62+
* @param RedirectFactory $redirectFactory
63+
* @param RawFactory $rawResultFactory
64+
*/
65+
public function __construct(
66+
Auth $auth,
67+
FormKeyValidator $formKeyValidator,
68+
BackendUrl $backendUrl,
69+
RedirectFactory $redirectFactory,
70+
RawFactory $rawResultFactory
71+
) {
72+
$this->auth = $auth;
73+
$this->formKeyValidator = $formKeyValidator;
74+
$this->backendUrl = $backendUrl;
75+
$this->redirectFactory = $redirectFactory;
76+
$this->rawResultFactory = $rawResultFactory;
77+
}
78+
79+
/**
80+
* @param RequestInterface $request
81+
* @param ActionInterface $action
82+
*
83+
* @return bool
84+
*/
85+
private function validateRequest(
86+
RequestInterface $request,
87+
ActionInterface $action
88+
): bool {
89+
/** @var bool|null $valid */
90+
$valid = null;
91+
92+
if ($action instanceof CsrfAwareActionInterface) {
93+
$valid = $action->validateForCsrf($request);
94+
}
95+
96+
if ($valid === null) {
97+
$validFormKey = true;
98+
$validSecretKey = true;
99+
if ($request instanceof HttpRequest && $request->isPost()) {
100+
$validFormKey = $this->formKeyValidator->validate($request);
101+
} elseif ($this->auth->isLoggedIn()
102+
&& $this->backendUrl->useSecretKey()
103+
) {
104+
$secretKeyValue = (string)$request->getParam(
105+
BackendUrl::SECRET_KEY_PARAM_NAME,
106+
null
107+
);
108+
$secretKey = $this->backendUrl->getSecretKey();
109+
$validSecretKey = ($secretKeyValue === $secretKey);
110+
}
111+
$valid = $validFormKey && $validSecretKey;
112+
}
113+
114+
return $valid;
115+
}
116+
117+
/**
118+
* @param RequestInterface $request
119+
* @param ActionInterface $action
120+
*
121+
* @return InvalidRequestException
122+
*/
123+
private function createException(
124+
RequestInterface $request,
125+
ActionInterface $action
126+
): InvalidRequestException {
127+
/** @var InvalidRequestException|null $exception */
128+
$exception = null;
129+
130+
if ($action instanceof CsrfAwareActionInterface) {
131+
$exception = $action->createCsrfValidationException($request);
132+
}
133+
134+
if ($exception === null) {
135+
if ($request instanceof HttpRequest && $request->isAjax()) {
136+
//Sending empty response for AJAX request since we don't know
137+
//the expected response format and it's pointless to redirect.
138+
/** @var RawResult $response */
139+
$response = $this->rawResultFactory->create();
140+
$response->setHttpResponseCode(401);
141+
$response->setContents('');
142+
$exception = new InvalidRequestException($response);
143+
} else {
144+
//For regular requests.
145+
$response = $this->redirectFactory->create()
146+
->setUrl($this->backendUrl->getStartupPageUrl());
147+
$exception = new InvalidRequestException(
148+
$response,
149+
[
150+
new Phrase(
151+
'Invalid security or form key. Please refresh the page.'
152+
)
153+
]
154+
);
155+
}
156+
}
157+
158+
return $exception;
159+
}
160+
161+
/**
162+
* @inheritDoc
163+
*/
164+
public function validate(
165+
RequestInterface $request,
166+
ActionInterface $action
167+
): void {
168+
if ($action instanceof AbstractAction) {
169+
//Abstract Action has build-in validation.
170+
if (!$action->_processUrlKeys()) {
171+
throw new InvalidRequestException($action->getResponse());
172+
}
173+
} else {
174+
//Fallback validation.
175+
if (!$this->validateRequest($request, $action)) {
176+
throw $this->createException($request, $action);
177+
}
178+
}
179+
}
180+
}

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<preference for="Magento\Framework\App\DefaultPathInterface" type="Magento\Backend\App\DefaultPath" />
1515
<preference for="Magento\Backend\App\ConfigInterface" type="Magento\Backend\App\Config" />
1616
<preference for="Magento\Framework\App\Response\Http\FileFactory" type="Magento\Backend\App\Response\Http\FileFactory" />
17+
<preference for="Magento\Framework\App\Request\ValidatorInterface"
18+
type="Magento\Backend\App\Request\BackendValidator" />
1719
<type name="Magento\Framework\Stdlib\DateTime\Timezone">
1820
<arguments>
1921
<argument name="scopeType" xsi:type="const">Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT</argument>

app/code/Magento/Backend/view/adminhtml/templates/page/header.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<?= /* @escapeNotVerified */ $edition ?>
1818
class="logo">
1919
<img class="logo-img" src="<?= /* @escapeNotVerified */ $block->getViewFileUrl($logoSrc) ?>"
20-
alt="<?= $block->escapeHtml(__('Magento Admin Panel')) ?>"/>
20+
alt="<?= $block->escapeHtml(__('Magento Admin Panel')) ?>" title="<?= $block->escapeHtml(__('Magento Admin Panel')) ?>"/>
2121
</a>
2222
<?php break; ?>
2323
<?php case 'user': ?>

app/code/Magento/Backend/view/adminhtml/templates/widget/form/element/gallery.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<?php foreach ($block->getValues()->getAttributeBackend()->getImageTypes() as $type): ?>
3535
<td class="gallery" align="center" style="vertical-align:bottom;">
3636
<a href="<?= /* @escapeNotVerified */ $image->setType($type)->getSourceUrl() ?>" target="_blank" onclick="imagePreview('<?= $block->getElement()->getHtmlId() ?>_image_<?= /* @escapeNotVerified */ $type ?>_<?= /* @escapeNotVerified */ $image->getValueId() ?>');return false;">
37-
<img id="<?= $block->getElement()->getHtmlId() ?>_image_<?= /* @escapeNotVerified */ $type ?>_<?= /* @escapeNotVerified */ $image->getValueId() ?>" src="<?= /* @escapeNotVerified */ $image->setType($type)->getSourceUrl() ?>?<?= /* @escapeNotVerified */ time() ?>" alt="<?= /* @escapeNotVerified */ $image->getValue() ?>" height="25" class="small-image-preview v-middle"/></a><br/>
37+
<img id="<?= $block->getElement()->getHtmlId() ?>_image_<?= /* @escapeNotVerified */ $type ?>_<?= /* @escapeNotVerified */ $image->getValueId() ?>" src="<?= /* @escapeNotVerified */ $image->setType($type)->getSourceUrl() ?>?<?= /* @escapeNotVerified */ time() ?>" alt="<?= /* @escapeNotVerified */ $image->getValue() ?>" title="<?= /* @escapeNotVerified */ $image->getValue() ?>" height="25" class="small-image-preview v-middle"/></a><br/>
3838
<input type="file" name="<?= /* @escapeNotVerified */ $block->getElement()->getName() ?>_<?= /* @escapeNotVerified */ $type ?>[<?= /* @escapeNotVerified */ $image->getValueId() ?>]" size="1"></td>
3939
<?php endforeach; ?>
4040
<td class="gallery" align="center" style="vertical-align:bottom;"><input type="input" name="<?= /* @escapeNotVerified */ $block->getElement()->getParentName() ?>[position][<?= /* @escapeNotVerified */ $image->getValueId() ?>]" value="<?= /* @escapeNotVerified */ $image->getPosition() ?>" id="<?= $block->getElement()->getHtmlId() ?>_position_<?= /* @escapeNotVerified */ $image->getValueId() ?>" size="3"/></td>

app/code/Magento/Braintree/Setup/Patch/Data/ConvertSerializedDataToJson.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Magento\Framework\Setup\Patch\PatchVersionInterface;
1313

1414
/**
15-
* Convert data fro php native serialized data to JSON.
15+
* Convert data from php native serialized data to JSON.
1616
*/
1717
class ConvertSerializedDataToJson implements DataPatchInterface, PatchVersionInterface
1818
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()" />
1313
<label class="label" data-bind="attr: {'for': getCode()}">
1414
<!-- PayPal Logo -->
15-
<img data-bind="attr: {src: getPaymentAcceptanceMarkSrc(), alt: $t('Acceptance Mark')}"
15+
<img data-bind="attr: {src: getPaymentAcceptanceMarkSrc(), alt: $t('Acceptance Mark')}, title: $t('Acceptance Mark')}"
1616
class="payment-icon"/>
1717
<!-- PayPal Logo -->
1818
<span text="getTitle()"></span>

app/code/Magento/Bundle/Test/Mftf/Data/BundleLinkData.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd">
1111
<entity name="ApiBundleLink" type="bundle_link">
1212
<var key="sku" entityKey="sku" entityType="product2"/>
13-
<var key="option_id" entityKey="option_id" entityType="bundle_options"/>
13+
<var key="option_id" entityKey="return" entityType="bundle_option"/>
1414
<var key="sku" entityKey="sku" entityType="product"/>
1515
<data key="qty">1</data>
16-
<data key="is_default">1</data>
16+
<data key="is_default">0</data>
1717
<data key="price">1.11</data>
1818
<data key="price_type">1</data>
1919
<data key="can_change_quantity">1</data>

app/code/Magento/Bundle/Test/Mftf/Data/BundleOptionData.xml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,34 @@
88

99
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd">
11-
<entity name="DropdownBundleOption" type="bundle_option">
11+
<entity name="DropDownBundleOption" type="bundle_option">
1212
<data key="title" unique="suffix">bundle-option-dropdown</data>
1313
<data key="required">true</data>
14-
<data key="type">dropdown</data>
14+
<data key="type">select</data>
15+
<data key="position">0</data>
16+
<var key="sku" entityKey="sku" entityType="product2"/>
17+
</entity>
18+
<entity name="RadioButtonsOption" type="bundle_option">
19+
<data key="title" unique="suffix">bundle-option-radio</data>
20+
<data key="required">true</data>
21+
<data key="type">radio</data>
1522
<data key="position">1</data>
1623
<var key="sku" entityKey="sku" entityType="product2"/>
1724
</entity>
25+
<entity name="CheckboxOption" type="bundle_option">
26+
<data key="title" unique="suffix">bundle-option-checkbox</data>
27+
<data key="required">true</data>
28+
<data key="type">checkbox</data>
29+
<data key="position">3</data>
30+
<var key="sku" entityKey="sku" entityType="product2"/>
31+
</entity>
32+
<entity name="MultipleSelectOption" type="bundle_option">
33+
<data key="title" unique="suffix">bundle-option-multipleselect</data>
34+
<data key="required">true</data>
35+
<data key="type">multi</data>
36+
<data key="position">4</data>
37+
<var key="sku" entityKey="sku" entityType="product2"/>
38+
</entity>
1839
<entity name="AllBundleOptions" type="bundle_options">
1940
<var key="sku" entityKey="sku" entityType="product"/>
2041
</entity>

app/code/Magento/Bundle/Test/Mftf/Data/CustomAttributeData.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@
1919
<data key="attribute_code">price_view</data>
2020
<data key="value">1</data>
2121
</entity>
22+
<entity name="CustomAttributePriceViewRange" type="custom_attribute">
23+
<data key="attribute_code">price_view</data>
24+
<data key="value">0</data>
25+
</entity>
2226
</entities>

app/code/Magento/Bundle/Test/Mftf/Data/ProductData.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,19 @@
4545
<requiredEntity type="custom_attribute">CustomAttributeDynamicPrice</requiredEntity>
4646
<requiredEntity type="custom_attribute">CustomAttributePriceView</requiredEntity>
4747
</entity>
48+
<entity name="ApiBundleProductPriceViewRange" type="product2">
49+
<data key="name" unique="suffix">Api Bundle Product</data>
50+
<data key="sku" unique="suffix">api-bundle-product</data>
51+
<data key="type_id">bundle</data>
52+
<data key="attribute_set_id">4</data>
53+
<data key="visibility">4</data>
54+
<data key="status">1</data>
55+
<data key="urlKey" unique="suffix">api-bundle-product</data>
56+
<requiredEntity type="custom_attribute">CustomAttributeCategoryIds</requiredEntity>
57+
<requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity>
58+
<requiredEntity type="custom_attribute">ApiProductDescription</requiredEntity>
59+
<requiredEntity type="custom_attribute">ApiProductShortDescription</requiredEntity>
60+
<requiredEntity type="custom_attribute">CustomAttributeDynamicPrice</requiredEntity>
61+
<requiredEntity type="custom_attribute">CustomAttributePriceViewRange</requiredEntity>
62+
</entity>
4863
</entities>

app/code/Magento/Bundle/Test/Mftf/Metadata/bundle_link-meta.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataOperation.xsd">
11-
<operation name="CreateBundleLink" dataType="bundle_link" type="create" auth="adminOauth" url="/V1/bundle-products/{sku}/links/{option_id}" method="POST">
11+
<operation name="CreateBundleLink" dataType="bundle_link" type="create" auth="adminOauth" url="/V1/bundle-products/{sku}/links/{return}" method="POST">
1212
<contentType>application/json</contentType>
1313
<object dataType="bundle_link" key="linkedProduct">
1414
<field key="sku">string</field>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
11+
<section name="StorefrontCategoryProductSection">
12+
<element name="priceToByProductId" type="text" selector="div[data-product-id='{{id}}'] .price-to" parameterized="true"/>
13+
<element name="priceFromByProductId" type="text" selector="div[data-product-id='{{id}}'] .price-from" parameterized="true"/>
14+
</section>
15+
</sections>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
11+
<section name="StorefrontProductInfoMainSection">
12+
<element name="priceFrom" type="text" selector=".product-info-price .price-from"/>
13+
<element name="priceTo" type="text" selector=".product-info-price .price-to"/>
14+
<element name="minPrice" type="text" selector="span[data-price-type='minPrice']"/>
15+
<element name="maxPrice" type="text" selector="span[data-price-type='minPrice']"/>
16+
</section>
17+
</sections>

0 commit comments

Comments
 (0)