Skip to content

Commit 5281114

Browse files
committed
Merge remote-tracking branch 'mainline/2.2-develop' into PANDA-FIXES-2.2
2 parents ce05a82 + b330f86 commit 5281114

File tree

11 files changed

+154
-48
lines changed

11 files changed

+154
-48
lines changed

app/code/Magento/Backend/Block/GlobalSearch.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public function getWidgetInitOptions()
7373
'filterProperty' => 'name',
7474
'preventClickPropagation' => false,
7575
'minLength' => 2,
76+
'submitInputOnEnter' => false,
7677
]
7778
];
7879
}

app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*/
77
namespace Magento\Catalog\Model\Product\Attribute;
88

9-
use Magento\Framework\Exception\InputException;
10-
119
class SetRepository implements \Magento\Catalog\Api\AttributeSetRepositoryInterface
1210
{
1311
/**
@@ -53,7 +51,7 @@ public function __construct(
5351
*/
5452
public function save(\Magento\Eav\Api\Data\AttributeSetInterface $attributeSet)
5553
{
56-
$this->validate($attributeSet);
54+
$this->validateBeforeSave($attributeSet);
5755
return $this->attributeSetRepository->save($attributeSet);
5856
}
5957

@@ -127,4 +125,29 @@ protected function validate(\Magento\Eav\Api\Data\AttributeSetInterface $attribu
127125
);
128126
}
129127
}
128+
129+
/**
130+
* Validate attribute set entity type id.
131+
*
132+
* @param \Magento\Eav\Api\Data\AttributeSetInterface $attributeSet
133+
* @return void
134+
* @throws \Magento\Framework\Exception\StateException
135+
* @throws \Magento\Framework\Exception\NoSuchEntityException
136+
* @throws \Magento\Framework\Exception\LocalizedException
137+
*/
138+
private function validateBeforeSave(\Magento\Eav\Api\Data\AttributeSetInterface $attributeSet)
139+
{
140+
$productEntityId = $this->eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY)->getId();
141+
$result = $attributeSet->getEntityTypeId() === $productEntityId;
142+
if (!$result && $attributeSet->getAttributeSetId()) {
143+
$existingAttributeSet = $this->attributeSetRepository->get($attributeSet->getAttributeSetId());
144+
$attributeSet->setEntityTypeId($existingAttributeSet->getEntityTypeId());
145+
$result = $existingAttributeSet->getEntityTypeId() === $productEntityId;
146+
}
147+
if (!$result) {
148+
throw new \Magento\Framework\Exception\StateException(
149+
__('Provided Attribute set non product Attribute set.')
150+
);
151+
}
152+
}
130153
}

app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Widget/Chooser/Sku.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ protected function _prepareColumns()
207207
public function getGridUrl()
208208
{
209209
return $this->getUrl(
210-
'catalog_rule/*/chooser',
210+
'*/*/chooser',
211211
['_current' => true, 'current_grid_id' => $this->getId(), 'collapse' => null]
212212
);
213213
}

app/code/Magento/CatalogSearch/Ui/DataProvider/Product/AddFulltextFilterToCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Magento\Ui\DataProvider\AddFilterToCollectionInterface;
1212

1313
/**
14-
* Class AddFulltextFilterToCollection
14+
* Adds FullText search to Product Data Provider
1515
*/
1616
class AddFulltextFilterToCollection implements AddFilterToCollectionInterface
1717
{

app/code/Magento/Paypal/Model/Express/Checkout.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,9 @@ public function place($token, $shippingMethodCode = null)
809809
case \Magento\Sales\Model\Order::STATE_PROCESSING:
810810
case \Magento\Sales\Model\Order::STATE_COMPLETE:
811811
case \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW:
812-
$this->orderSender->send($order);
812+
if (!$order->getEmailSent()) {
813+
$this->orderSender->send($order);
814+
}
813815
$this->_checkoutSession->start();
814816
break;
815817
default:

app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\VersionContro
4545
*/
4646
protected $_quoteConfig;
4747

48+
/**
49+
* @var \Magento\Store\Model\StoreManagerInterface|null
50+
*/
51+
private $storeManager;
52+
4853
/**
4954
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
5055
* @param \Psr\Log\LoggerInterface $logger
@@ -56,6 +61,7 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\VersionContro
5661
* @param \Magento\Quote\Model\Quote\Config $quoteConfig
5762
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
5863
* @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
64+
* @param \Magento\Store\Model\StoreManagerInterface|null $storeManager
5965
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
6066
*/
6167
public function __construct(
@@ -68,7 +74,8 @@ public function __construct(
6874
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
6975
\Magento\Quote\Model\Quote\Config $quoteConfig,
7076
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
71-
\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
77+
\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null,
78+
\Magento\Store\Model\StoreManagerInterface $storeManager = null
7279
) {
7380
parent::__construct(
7481
$entityFactory,
@@ -82,6 +89,10 @@ public function __construct(
8289
$this->_itemOptionCollectionFactory = $itemOptionCollectionFactory;
8390
$this->_productCollectionFactory = $productCollectionFactory;
8491
$this->_quoteConfig = $quoteConfig;
92+
93+
// Backward compatibility constructor parameters
94+
$this->storeManager = $storeManager ?:
95+
\Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Store\Model\StoreManagerInterface::class);
8596
}
8697

8798
/**
@@ -101,7 +112,10 @@ protected function _construct()
101112
*/
102113
public function getStoreId()
103114
{
104-
return (int)$this->_productCollectionFactory->create()->getStoreId();
115+
// Fallback to current storeId if no quote is provided
116+
// (see https://github.com/magento/magento2/commit/9d3be732a88884a66d667b443b3dc1655ddd0721)
117+
return $this->_quote === null ?
118+
(int) $this->storeManager->getStore()->getId() : (int) $this->_quote->getStoreId();
105119
}
106120

107121
/**

app/code/Magento/Review/view/frontend/templates/view.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<div class="actions">
5050
<div class="secondary">
5151
<a class="action back" href="<?= $block->escapeUrl($block->getBackUrl()) ?>">
52-
<span><?= $block->escapeHtml(__('Back to Product Reviews')) ?></a></span>
52+
<span><?= $block->escapeHtml(__('Back to Product Reviews')) ?></span>
5353
</a>
5454
</div>
5555
</div>

app/code/Magento/Search/Model/SynonymAnalyzer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function getSynonymsForPhrase($phrase)
8282
/**
8383
* Helper method to find the matching of $pattern to $synonymGroupsToExamine.
8484
* If matches, the particular array index is returned.
85-
* Otherwise false will be returned.
85+
* Otherwise null will be returned.
8686
*
8787
* @param string $pattern
8888
* @param array $synonymGroupsToExamine

dev/tests/api-functional/testsuite/Magento/Catalog/Api/AttributeSetRepositoryTest.php

Lines changed: 69 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Catalog\Api;
77

8+
use Magento\Eav\Api\Data\AttributeSetInterface;
89
use Magento\TestFramework\TestCase\WebapiAbstract;
910

1011
class AttributeSetRepositoryTest extends WebapiAbstract
@@ -71,38 +72,39 @@ public function testSave()
7172
{
7273
$attributeSetName = 'empty_attribute_set';
7374
$attributeSet = $this->getAttributeSetByName($attributeSetName);
74-
$serviceInfo = [
75-
'rest' => [
76-
'resourcePath' => '/V1/products/attribute-sets/' . $attributeSet->getId(),
77-
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT,
78-
],
79-
'soap' => [
80-
'service' => 'catalogAttributeSetRepositoryV1',
81-
'serviceVersion' => 'V1',
82-
'operation' => 'catalogAttributeSetRepositoryV1Save',
75+
$updatedSortOrder = $attributeSet->getSortOrder() + 200;
76+
$arguments = [
77+
'attributeSet' => [
78+
'attribute_set_id' => $attributeSet->getId(),
79+
// name is the same, because it is used by fixture rollback script
80+
'attribute_set_name' => $attributeSet->getAttributeSetName(),
81+
'entity_type_id' => $attributeSet->getEntityTypeId(),
82+
'sort_order' => $updatedSortOrder,
8383
],
8484
];
85+
$result = $this->save($attributeSet, $arguments);
86+
$this->assertAttributeSetData($result, $attributeSetName, $updatedSortOrder);
87+
}
8588

89+
/**
90+
* Test update attribute set without specified optional "entity_type_id" param.
91+
*
92+
* @magentoApiDataFixture Magento/Eav/_files/empty_attribute_set.php
93+
*/
94+
public function testUpdateWithoutEntityType()
95+
{
96+
$attributeSetName = 'empty_attribute_set';
97+
$attributeSet = $this->getAttributeSetByName('empty_attribute_set');
8698
$updatedSortOrder = $attributeSet->getSortOrder() + 200;
87-
8899
$arguments = [
89100
'attributeSet' => [
90101
'attribute_set_id' => $attributeSet->getId(),
91-
// name is the same, because it is used by fixture rollback script
92102
'attribute_set_name' => $attributeSet->getAttributeSetName(),
93-
'entity_type_id' => $attributeSet->getEntityTypeId(),
94103
'sort_order' => $updatedSortOrder,
95104
],
96105
];
97-
$result = $this->_webApiCall($serviceInfo, $arguments);
98-
$this->assertNotNull($result);
99-
// Reload attribute set data
100-
$attributeSet = $this->getAttributeSetByName($attributeSetName);
101-
$this->assertEquals($attributeSet->getAttributeSetId(), $result['attribute_set_id']);
102-
$this->assertEquals($attributeSet->getAttributeSetName(), $result['attribute_set_name']);
103-
$this->assertEquals($attributeSet->getEntityTypeId(), $result['entity_type_id']);
104-
$this->assertEquals($updatedSortOrder, $result['sort_order']);
105-
$this->assertEquals($attributeSet->getSortOrder(), $result['sort_order']);
106+
$result = $this->save($attributeSet, $arguments);
107+
$this->assertAttributeSetData($result, $attributeSetName, $updatedSortOrder);
106108
}
107109

108110
/**
@@ -215,4 +217,50 @@ protected function getAttributeSetByName($attributeSetName)
215217
}
216218
return $attributeSet;
217219
}
220+
221+
/**
222+
* Save given attribute set with specified arguments.
223+
*
224+
* @param AttributeSetInterface $attributeSet
225+
* @param array $arguments
226+
* @return array
227+
*/
228+
private function save(AttributeSetInterface $attributeSet, array $arguments)
229+
{
230+
$serviceInfo = [
231+
'rest' => [
232+
'resourcePath' => '/V1/products/attribute-sets/' . $attributeSet->getAttributeSetId(),
233+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT,
234+
],
235+
'soap' => [
236+
'service' => 'catalogAttributeSetRepositoryV1',
237+
'serviceVersion' => 'V1',
238+
'operation' => 'catalogAttributeSetRepositoryV1Save',
239+
],
240+
];
241+
242+
return $this->_webApiCall($serviceInfo, $arguments);
243+
}
244+
245+
/**
246+
* Check attribute set data.
247+
*
248+
* @param string $attributeSetName
249+
* @param array $result
250+
* @param int $updatedSortOrder
251+
*/
252+
private function assertAttributeSetData(
253+
array $result,
254+
string $attributeSetName,
255+
int $updatedSortOrder
256+
) {
257+
$this->assertNotNull($result);
258+
// Reload attribute set data
259+
$attributeSet = $this->getAttributeSetByName($attributeSetName);
260+
$this->assertEquals($attributeSet->getAttributeSetId(), $result['attribute_set_id']);
261+
$this->assertEquals($attributeSet->getAttributeSetName(), $result['attribute_set_name']);
262+
$this->assertEquals($attributeSet->getEntityTypeId(), $result['entity_type_id']);
263+
$this->assertEquals($updatedSortOrder, $result['sort_order']);
264+
$this->assertEquals($attributeSet->getSortOrder(), $result['sort_order']);
265+
}
218266
}

lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FulltextFilter.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ function ($column) use ($alias) {
6262
return $columns;
6363
}
6464

65+
/**
66+
* Escape against value
67+
* @param string $value
68+
* @return string
69+
*/
70+
private function escapeAgainstValue(string $value): string
71+
{
72+
return preg_replace('/([+\-><\(\)~*\"@]+)/', ' ', $value);
73+
}
74+
6575
/**
6676
* Apply fulltext filters
6777
*
@@ -86,7 +96,7 @@ public function apply(Collection $collection, Filter $filter)
8696
$collection->getSelect()
8797
->where(
8898
'MATCH(' . implode(',', $columns) . ') AGAINST(?)',
89-
$filter->getValue()
99+
$this->escapeAgainstValue($filter->getValue())
90100
);
91101
}
92102
}

0 commit comments

Comments
 (0)