Skip to content

Commit 71d4da5

Browse files
author
Magento CICD
authored
merge magento/2.3-develop into magento-architects/MAGETWO-90358-Extension-Attributes
2 parents d63c3d4 + 4a61ed6 commit 71d4da5

File tree

154 files changed

+2091
-936
lines changed

Some content is hidden

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

154 files changed

+2091
-936
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
1-
<!--- Provide a general summary of the issue in the Title above -->
2-
<!--- Before adding new issues, please, check this article https://github.com/magento/magento2/wiki/Issue-reporting-guidelines-->
1+
<!---
2+
Thank you for contributing to Magento.
3+
To help us process this issue we recommend that you add the following information:
4+
- Summary of the issue,
5+
- Information on your environment,
6+
- Steps to reproduce,
7+
- Expected and actual results,
8+
9+
Please also have a look at our guidelines article before adding a new issue https://github.com/magento/magento2/wiki/Issue-reporting-guidelines
10+
-->
311

412
### Preconditions
5-
<!--- Provide a more detailed information of environment you use -->
6-
<!--- Magento version, tag, HEAD, etc., PHP & MySQL version, etc.. -->
13+
<!---
14+
Please provide as detailed information about your environment as possible.
15+
For example Magento version, tag, HEAD, PHP & MySQL version, etc..
16+
-->
717
1.
818
2.
919

1020
### Steps to reproduce
11-
<!--- Provide a set of unambiguous steps to reproduce this bug include code, if relevant -->
21+
<!---
22+
It is important to provide a set of clear steps to reproduce this bug.
23+
If relevant please include code samples
24+
-->
1225
1.
1326
2.
1427
3.
1528

1629
### Expected result
1730
<!--- Tell us what should happen -->
18-
1.
31+
1. [Screenshot, logs]
1932

2033
### Actual result
2134
<!--- Tell us what happens instead -->
2235
1. [Screenshot, logs]
23-
24-
<!--- (This may be platform independent comment) -->

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
1-
<!--- Provide a general summary of the Pull Request in the Title above -->
1+
<!---
2+
Thank you for contributing to Magento.
3+
To help us process this pull request we recommend that you add the following information:
4+
- Summary of the pull request,
5+
- Issue(s) related to the changes made,
6+
- Manual testing scenarios,
7+
-->
8+
9+
<!--- Please provide a general summary of the Pull Request in the Title above -->
210

311
### Description
4-
<!--- Provide a description of the changes proposed in the pull request -->
12+
<!---
13+
Please provide a description of the changes proposed in the pull request.
14+
Letting us know what has changed and why it needed changing will help us validate this pull request.
15+
-->
516

617
### Fixed Issues (if relevant)
7-
<!--- Provide a list of fixed issues in the format magento/magento2#<issue_number>, if relevant -->
18+
<!---
19+
If relevant, please provide a list of fixed issues in the format magento/magento2#<issue_number>.
20+
There could be 1 or more issues linked here and it will help us find some more information about the reasoning behind this change.
21+
-->
822
1. magento/magento2#<issue_number>: Issue title
923
2. ...
1024

1125
### Manual testing scenarios
12-
<!--- Provide a set of unambiguous steps to test the proposed code change -->
26+
<!---
27+
Please provide a set of unambiguous steps to test the proposed code change.
28+
Giving us manual testing scenarios will help with the processing and validation process.
29+
-->
1330
1. ...
1431
2. ...
1532

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ language: php
1818
php:
1919
- 7.1
2020
- 7.2
21-
git:
22-
depth: 5
2321
env:
2422
global:
2523
- COMPOSER_BIN_DIR=~/bin

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function render(\Magento\Framework\DataObject $row)
6565
*/
6666
protected function _getCheckboxHtml($value, $checked)
6767
{
68-
$id = 'id_' . rand(0, 999);
68+
$id = 'id_' . random_int(0, 999);
6969
$html = '<label class="data-grid-checkbox-cell-inner" for="'. $id .'">';
7070
$html .= '<input type="checkbox" name="' . $this->getColumn()->getName() . '" ';
7171
$html .= 'id="' . $id . '" data-role="select-row"';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@
447447
<!-- PayPal value handlers infrastructure -->
448448
<type name="Magento\Braintree\Gateway\Response\PayPal\VaultDetailsHandler">
449449
<arguments>
450-
<argument name="paymentTokenFactory" xsi:type="object">Magento\Vault\Model\AccountPaymentTokenFactory</argument>
450+
<argument name="paymentTokenFactory" xsi:type="object">Magento\Vault\Api\Data\PaymentTokenFactoryInterface</argument>
451451
</arguments>
452452
</type>
453453
<virtualType name="BraintreePayPalValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool">

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ public function execute()
139139
->setName($name)
140140
->getAttributeSet();
141141
} catch (AlreadyExistsException $alreadyExists) {
142-
$this->messageManager->addErrorMessage(
143-
__('A "%1" attribute set name already exists. Create a new name and try again.', $name)
144-
);
142+
$this->messageManager->addErrorMessage(__('An attribute set named \'%1\' already exists.', $name));
145143
$this->_session->setAttributeData($data);
146144
return $this->returnResult('catalog/*/edit', ['_current' => true], ['error' => true]);
147145
} catch (LocalizedException $e) {
@@ -202,6 +200,8 @@ public function execute()
202200
}
203201
}
204202

203+
$data = $this->presentation->convertPresentationDataToInputType($data);
204+
205205
if ($attributeId) {
206206
if (!$model->getId()) {
207207
$this->messageManager->addErrorMessage(__('This attribute no longer exists.'));
@@ -216,7 +216,7 @@ public function execute()
216216

217217
$data['attribute_code'] = $model->getAttributeCode();
218218
$data['is_user_defined'] = $model->getIsUserDefined();
219-
$data['frontend_input'] = $model->getFrontendInput();
219+
$data['frontend_input'] = $data['frontend_input'] ?? $model->getFrontendInput();
220220
} else {
221221
/**
222222
* @todo add to helper and specify all relations for properties
@@ -229,8 +229,6 @@ public function execute()
229229
);
230230
}
231231

232-
$data = $this->presentation->convertPresentationDataToInputType($data);
233-
234232
$data += ['is_filterable' => 0, 'is_filterable_in_search' => 0];
235233

236234
if ($model->getIsUserDefined() === null || $model->getIsUserDefined() != 0) {

app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ protected function getTemporaryTreeIndexTableName()
597597
if (empty($this->tempTreeIndexTableName)) {
598598
$this->tempTreeIndexTableName = $this->connection->getTableName('temp_catalog_category_tree_index')
599599
. '_'
600-
. substr(md5(time() . rand(0, 999999999)), 0, 8);
600+
. substr(md5(time() . random_int(0, 999999999)), 0, 8);
601601
}
602602

603603
return $this->tempTreeIndexTableName;
@@ -659,25 +659,30 @@ protected function makeTempCategoryTreeIndex()
659659
*/
660660
protected function fillTempCategoryTreeIndex($temporaryName)
661661
{
662-
// This finds all children (cc2) that descend from a parent (cc) by path.
663-
// For example, cc.path may be '1/2', and cc2.path may be '1/2/3/4/5'.
664-
$temporarySelect = $this->connection->select()->from(
665-
['cc' => $this->getTable('catalog_category_entity')],
666-
['parent_id' => 'entity_id']
667-
)->joinInner(
668-
['cc2' => $this->getTable('catalog_category_entity')],
669-
'cc2.path LIKE ' . $this->connection->getConcatSql(
670-
[$this->connection->quoteIdentifier('cc.path'), $this->connection->quote('/%')]
671-
),
672-
['child_id' => 'entity_id']
662+
$selects = $this->prepareSelectsByRange(
663+
$this->connection->select()
664+
->from(
665+
['c' => $this->getTable('catalog_category_entity')],
666+
['entity_id', 'path']
667+
),
668+
'entity_id'
673669
);
674670

675-
$this->connection->query(
676-
$temporarySelect->insertFromSelect(
677-
$temporaryName,
678-
['parent_id', 'child_id']
679-
)
680-
);
671+
foreach ($selects as $select) {
672+
$values = [];
673+
674+
foreach ($this->connection->fetchAll($select) as $category) {
675+
foreach (explode('/', $category['path']) as $parentId) {
676+
if ($parentId !== $category['entity_id']) {
677+
$values[] = [$parentId, $category['entity_id']];
678+
}
679+
}
680+
}
681+
682+
if (count($values) > 0) {
683+
$this->connection->insertArray($temporaryName, ['parent_id', 'child_id'], $values);
684+
}
685+
}
681686
}
682687

683688
/**

app/code/Magento/Catalog/Model/Product/Attribute/Frontend/Inputtype/Presentation.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\Catalog\Model\Product\Attribute\Frontend\Inputtype;
810

911
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
@@ -19,9 +21,9 @@ class Presentation
1921
* Get input type for presentation layer from stored input type.
2022
*
2123
* @param Attribute $attribute
22-
* @return string
24+
* @return string|null
2325
*/
24-
public function getPresentationInputType(Attribute $attribute)
26+
public function getPresentationInputType(Attribute $attribute) :?string
2527
{
2628
$inputType = $attribute->getFrontendInput();
2729
if ($inputType == 'textarea' && $attribute->getIsWysiwygEnabled()) {
@@ -37,12 +39,12 @@ public function getPresentationInputType(Attribute $attribute)
3739
*
3840
* @return array
3941
*/
40-
public function convertPresentationDataToInputType(array $data)
42+
public function convertPresentationDataToInputType(array $data) : array
4143
{
42-
if ($data['frontend_input'] === 'texteditor') {
44+
if (isset($data['frontend_input']) && $data['frontend_input'] === 'texteditor') {
4345
$data['is_wysiwyg_enabled'] = 1;
4446
$data['frontend_input'] = 'textarea';
45-
} elseif ($data['frontend_input'] === 'textarea') {
47+
} elseif (isset($data['frontend_input']) && $data['frontend_input'] === 'textarea') {
4648
$data['is_wysiwyg_enabled'] = 0;
4749
}
4850
return $data;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute\Frontend\InputType;
9+
10+
class PresentationTest extends \PHPUnit\Framework\TestCase
11+
{
12+
/**
13+
* @var \Magento\Catalog\Model\Product\Attribute\Frontend\Inputtype\Presentation
14+
*/
15+
private $presentation;
16+
17+
/**
18+
* @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute| \PHPUnit_Framework_MockObject_MockObject
19+
*/
20+
private $attributeMock;
21+
22+
protected function setUp()
23+
{
24+
$this->presentation = new \Magento\Catalog\Model\Product\Attribute\Frontend\Inputtype\Presentation();
25+
$this->attributeMock = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
26+
->disableOriginalConstructor()
27+
->getMock();
28+
}
29+
30+
/**
31+
* @param string $inputType
32+
* @param boolean $isWysiwygEnabled
33+
* @param string $expectedResult
34+
* @dataProvider getPresentationInputTypeDataProvider
35+
*/
36+
public function testGetPresentationInputType(string $inputType, bool $isWysiwygEnabled, string $expectedResult)
37+
{
38+
$this->attributeMock->expects($this->once())->method('getFrontendInput')->willReturn($inputType);
39+
$this->attributeMock->expects($this->any())->method('getIsWysiwygEnabled')->willReturn($isWysiwygEnabled);
40+
$this->assertEquals($expectedResult, $this->presentation->getPresentationInputType($this->attributeMock));
41+
}
42+
43+
public function getPresentationInputTypeDataProvider()
44+
{
45+
return [
46+
'attribute_is_textarea_and_wysiwyg_enabled' => ['textarea', true, 'texteditor'],
47+
'attribute_is_input_and_wysiwyg_enabled' => ['input', true, 'input'],
48+
'attribute_is_textarea_and_wysiwyg_disabled' => ['textarea', false, 'textarea'],
49+
];
50+
}
51+
52+
/**
53+
* @param array $data
54+
* @param array $expectedResult
55+
* @dataProvider convertPresentationDataToInputTypeDataProvider
56+
*/
57+
public function testConvertPresentationDataToInputType(array $data, array $expectedResult)
58+
{
59+
$this->assertEquals($expectedResult, $this->presentation->convertPresentationDataToInputType($data));
60+
}
61+
62+
public function convertPresentationDataToInputTypeDataProvider()
63+
{
64+
return [
65+
[['key' => 'value'], ['key' => 'value']],
66+
[
67+
['frontend_input' => 'texteditor'],
68+
['frontend_input' => 'textarea', 'is_wysiwyg_enabled' => 1]
69+
],
70+
[
71+
['frontend_input' => 'textarea'],
72+
['frontend_input' => 'textarea', 'is_wysiwyg_enabled' => 0]
73+
],
74+
[
75+
['frontend_input' => 'input'],
76+
['frontend_input' => 'input']
77+
]
78+
];
79+
}
80+
}

app/code/Magento/Catalog/view/base/web/js/price-options.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ define([
2020
optionConfig: {},
2121
optionHandlers: {},
2222
optionTemplate: '<%= data.label %>' +
23-
'<% if (data.finalPrice.value) { %>' +
23+
'<% if (data.finalPrice.value > 0) { %>' +
2424
' +<%- data.finalPrice.formatted %>' +
25+
'<% } else if (data.finalPrice.value < 0) { %>' +
26+
' <%- data.finalPrice.formatted %>' +
2527
'<% } %>',
2628
controlContainer: 'dd'
2729
};

0 commit comments

Comments
 (0)