Skip to content

Commit 04c94b3

Browse files
author
Magento CICD
authored
merge magento/2.3-develop into magento-qwerty/PR-13032018
2 parents bc25aa3 + 05ccc44 commit 04c94b3

File tree

22 files changed

+613
-140
lines changed

22 files changed

+613
-140
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ define([
6161
},
6262

6363
/**
64-
* @returns {Bool}
64+
* @returns {Boolean}
6565
*/
6666
isVaultEnabled: function () {
6767
return this.vaultEnabler.isVaultEnabled();
@@ -142,11 +142,20 @@ define([
142142
return true;
143143
},
144144

145+
/**
146+
* Returns state of place order button
147+
* @returns {Boolean}
148+
*/
149+
isButtonActive: function () {
150+
return this.isActive() && this.isPlaceOrderActionAllowed();
151+
},
152+
145153
/**
146154
* Trigger order placing
147155
*/
148156
placeOrderClick: function () {
149157
if (this.validateCardType()) {
158+
this.isPlaceOrderActionAllowed(false);
150159
$(this.getSelector('submit')).trigger('click');
151160
}
152161
},

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@
141141
data-bind="
142142
click: placeOrderClick,
143143
attr: {title: $t('Place Order')},
144-
css: {disabled: !isPlaceOrderActionAllowed()},
145-
enable: isActive()
144+
enable: isButtonActive()
146145
"
147146
disabled>
148147
<span data-bind="i18n: 'Place Order'"></span>

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function getGroupTreeJson()
233233
/* @var $node \Magento\Eav\Model\Entity\Attribute\Group */
234234
foreach ($groups as $node) {
235235
$item = [];
236-
$item['text'] = $node->getAttributeGroupName();
236+
$item['text'] = $this->escapeHtml($node->getAttributeGroupName());
237237
$item['id'] = $node->getAttributeGroupId();
238238
$item['cls'] = 'folder';
239239
$item['allowDrop'] = true;
@@ -280,7 +280,7 @@ public function getAttributeTreeJson()
280280

281281
foreach ($attributes as $child) {
282282
$attr = [
283-
'text' => $child->getAttributeCode(),
283+
'text' => $this->escapeHtml($child->getAttributeCode()),
284284
'id' => $child->getAttributeId(),
285285
'cls' => 'leaf',
286286
'allowDrop' => false,

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/set/main.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@
315315
},
316316

317317
validateGroupName : function(name, exceptNodeId) {
318-
name = name.strip();
318+
name = name.strip().escapeHTML();
319319
var result = true;
320320
if (name === '') {
321321
result = false;

app/code/Magento/CatalogInventory/Model/Indexer/Stock/AbstractAction.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Magento\Framework\App\ObjectManager;
1212
use Magento\Framework\App\ResourceConnection;
13+
use Magento\Framework\EntityManager\MetadataPool;
1314

1415
/**
1516
* Abstract action reindex class
@@ -70,25 +71,33 @@ abstract class AbstractAction
7071
*/
7172
private $cacheCleaner;
7273

74+
/**
75+
* @var MetadataPool
76+
*/
77+
private $metadataPool;
78+
7379
/**
7480
* @param ResourceConnection $resource
7581
* @param \Magento\CatalogInventory\Model\ResourceModel\Indexer\StockFactory $indexerFactory
7682
* @param \Magento\Catalog\Model\Product\Type $catalogProductType
7783
* @param \Magento\Framework\Indexer\CacheContext $cacheContext
7884
* @param \Magento\Framework\Event\ManagerInterface $eventManager
85+
* @param MetadataPool|null $metadataPool
7986
*/
8087
public function __construct(
8188
ResourceConnection $resource,
8289
\Magento\CatalogInventory\Model\ResourceModel\Indexer\StockFactory $indexerFactory,
8390
\Magento\Catalog\Model\Product\Type $catalogProductType,
8491
\Magento\Framework\Indexer\CacheContext $cacheContext,
85-
\Magento\Framework\Event\ManagerInterface $eventManager
92+
\Magento\Framework\Event\ManagerInterface $eventManager,
93+
MetadataPool $metadataPool = null
8694
) {
8795
$this->_resource = $resource;
8896
$this->_indexerFactory = $indexerFactory;
8997
$this->_catalogProductType = $catalogProductType;
9098
$this->cacheContext = $cacheContext;
9199
$this->eventManager = $eventManager;
100+
$this->metadataPool = $metadataPool ?: ObjectManager::getInstance()->get(MetadataPool::class);
92101
}
93102

94103
/**
@@ -154,10 +163,15 @@ protected function _getTable($entityName)
154163
public function getRelationsByChild($childIds)
155164
{
156165
$connection = $this->_getConnection();
157-
$select = $connection->select()
158-
->from($this->_getTable('catalog_product_relation'), 'parent_id')
159-
->where('child_id IN(?)', $childIds);
160-
166+
$linkField = $this->metadataPool->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class)
167+
->getLinkField();
168+
$select = $connection->select()->from(
169+
['cpe' => $this->_getTable('catalog_product_entity')],
170+
'entity_id'
171+
)->join(
172+
['relation' => $this->_getTable('catalog_product_relation')],
173+
'relation.parent_id = cpe.' . $linkField
174+
)->where('child_id IN(?)', $childIds);
161175
return $connection->fetchCol($select);
162176
}
163177

@@ -230,7 +244,8 @@ protected function _reindexRows($productIds = [])
230244
if (!is_array($productIds)) {
231245
$productIds = [$productIds];
232246
}
233-
247+
$parentIds = $this->getRelationsByChild($productIds);
248+
$productIds = $parentIds ? array_unique(array_merge($parentIds, $productIds)) : $productIds;
234249
$this->getCacheCleaner()->clean($productIds, function () use ($productIds) {
235250
$this->doReindex($productIds);
236251
});
@@ -248,13 +263,10 @@ private function doReindex($productIds = [])
248263
{
249264
$connection = $this->_getConnection();
250265

251-
$parentIds = $this->getRelationsByChild($productIds);
252-
$processIds = $parentIds ? array_merge($parentIds, $productIds) : $productIds;
253-
254266
// retrieve product types by processIds
255267
$select = $connection->select()
256268
->from($this->_getTable('catalog_product_entity'), ['entity_id', 'type_id'])
257-
->where('entity_id IN(?)', $processIds);
269+
->where('entity_id IN(?)', $productIds);
258270
$pairs = $connection->fetchPairs($select);
259271

260272
$byType = [];
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\CatalogInventory\Model\Plugin;
7+
8+
use Magento\Catalog\Model\Product\Action as ProductAction;
9+
10+
/**
11+
* Plugin for Magento\Catalog\Model\Product\Action
12+
*/
13+
class ReindexUpdatedProducts
14+
{
15+
/**
16+
* @var \Magento\CatalogInventory\Model\Indexer\Stock\Processor
17+
*/
18+
private $indexerProcessor;
19+
20+
/**
21+
* @param \Magento\CatalogInventory\Model\Indexer\Stock\Processor $indexerProcessor
22+
*/
23+
public function __construct(\Magento\CatalogInventory\Model\Indexer\Stock\Processor $indexerProcessor)
24+
{
25+
$this->indexerProcessor = $indexerProcessor;
26+
}
27+
28+
/**
29+
* Reindex on product attribute mass change
30+
*
31+
* @param ProductAction $subject
32+
* @param ProductAction $action
33+
* @param array $productIds
34+
* @return ProductAction
35+
*
36+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
37+
*/
38+
public function afterUpdateAttributes(
39+
ProductAction $subject,
40+
ProductAction $action,
41+
$productIds
42+
) {
43+
$this->indexerProcessor->reindexList(array_unique($productIds));
44+
return $action;
45+
}
46+
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@
7878
<type name="Magento\Catalog\Model\Product">
7979
<plugin name="catalogInventoryAfterLoad" type="Magento\CatalogInventory\Model\Plugin\AfterProductLoad"/>
8080
</type>
81+
<type name="Magento\Catalog\Model\Product\Action">
82+
<plugin name="ReindexUpdatedProducts" type="Magento\CatalogInventory\Model\Plugin\ReindexUpdatedProducts"/>
83+
</type>
84+
<type name="Magento\CatalogInventory\Setup\UpgradeData">
85+
<arguments>
86+
<argument name="indexerProcessor" xsi:type="object">Magento\CatalogInventory\Model\Indexer\Stock\Processor</argument>
87+
</arguments>
88+
</type>
8189
<type name="Magento\Catalog\Model\ResourceModel\Product\CompositeBaseSelectProcessor">
8290
<arguments>
8391
<argument name="baseSelectProcessors" xsi:type="array">

app/code/Magento/Customer/Model/Plugin/CustomerNotification.php

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Magento\Framework\App\Area;
1313
use Magento\Framework\App\RequestInterface;
1414
use Magento\Framework\App\State;
15+
use Magento\Framework\Exception\NoSuchEntityException;
16+
use Psr\Log\LoggerInterface;
1517

1618
class CustomerNotification
1719
{
@@ -35,24 +37,32 @@ class CustomerNotification
3537
*/
3638
private $state;
3739

40+
/**
41+
* @var LoggerInterface
42+
*/
43+
private $logger;
44+
3845
/**
3946
* Initialize dependencies.
4047
*
4148
* @param Session $session
4249
* @param NotificationStorage $notificationStorage
4350
* @param State $state
4451
* @param CustomerRepositoryInterface $customerRepository
52+
* @param LoggerInterface $logger
4553
*/
4654
public function __construct(
4755
Session $session,
4856
NotificationStorage $notificationStorage,
4957
State $state,
50-
CustomerRepositoryInterface $customerRepository
58+
CustomerRepositoryInterface $customerRepository,
59+
LoggerInterface $logger
5160
) {
5261
$this->session = $session;
5362
$this->notificationStorage = $notificationStorage;
5463
$this->state = $state;
5564
$this->customerRepository = $customerRepository;
65+
$this->logger = $logger;
5666
}
5767

5868
/**
@@ -63,17 +73,23 @@ public function __construct(
6373
*/
6474
public function beforeDispatch(AbstractAction $subject, RequestInterface $request)
6575
{
76+
$customerId = $this->session->getCustomerId();
77+
6678
if ($this->state->getAreaCode() == Area::AREA_FRONTEND && $request->isPost()
6779
&& $this->notificationStorage->isExists(
6880
NotificationStorage::UPDATE_CUSTOMER_SESSION,
69-
$this->session->getCustomerId()
81+
$customerId
7082
)
7183
) {
72-
$customer = $this->customerRepository->getById($this->session->getCustomerId());
73-
$this->session->setCustomerData($customer);
74-
$this->session->setCustomerGroupId($customer->getGroupId());
75-
$this->session->regenerateId();
76-
$this->notificationStorage->remove(NotificationStorage::UPDATE_CUSTOMER_SESSION, $customer->getId());
84+
try {
85+
$customer = $this->customerRepository->getById($customerId);
86+
$this->session->setCustomerData($customer);
87+
$this->session->setCustomerGroupId($customer->getGroupId());
88+
$this->session->regenerateId();
89+
$this->notificationStorage->remove(NotificationStorage::UPDATE_CUSTOMER_SESSION, $customer->getId());
90+
} catch (NoSuchEntityException $e) {
91+
$this->logger->error($e);
92+
}
7793
}
7894
}
7995
}

app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
namespace Magento\Customer\Model\ResourceModel;
88

99
use Magento\Customer\Api\CustomerMetadataInterface;
10+
use Magento\Customer\Model\Customer\NotificationStorage;
1011
use Magento\Framework\Api\DataObjectHelper;
1112
use Magento\Framework\Api\ImageProcessorInterface;
1213
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
1314
use Magento\Framework\Api\SearchCriteriaInterface;
15+
use Magento\Framework\App\ObjectManager;
1416

1517
/**
1618
* Customer repository.
@@ -88,6 +90,11 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte
8890
*/
8991
private $collectionProcessor;
9092

93+
/**
94+
* @var NotificationStorage
95+
*/
96+
private $notificationStorage;
97+
9198
/**
9299
* @param \Magento\Customer\Model\CustomerFactory $customerFactory
93100
* @param \Magento\Customer\Model\Data\CustomerSecureFactory $customerSecureFactory
@@ -103,6 +110,7 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte
103110
* @param ImageProcessorInterface $imageProcessor
104111
* @param \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor
105112
* @param CollectionProcessorInterface $collectionProcessor
113+
* @param NotificationStorage $notificationStorage
106114
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
107115
*/
108116
public function __construct(
@@ -119,7 +127,8 @@ public function __construct(
119127
DataObjectHelper $dataObjectHelper,
120128
ImageProcessorInterface $imageProcessor,
121129
\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor,
122-
CollectionProcessorInterface $collectionProcessor = null
130+
CollectionProcessorInterface $collectionProcessor,
131+
NotificationStorage $notificationStorage
123132
) {
124133
$this->customerFactory = $customerFactory;
125134
$this->customerSecureFactory = $customerSecureFactory;
@@ -134,7 +143,8 @@ public function __construct(
134143
$this->dataObjectHelper = $dataObjectHelper;
135144
$this->imageProcessor = $imageProcessor;
136145
$this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
137-
$this->collectionProcessor = $collectionProcessor ?: $this->getCollectionProcessor();
146+
$this->collectionProcessor = $collectionProcessor;
147+
$this->notificationStorage = $notificationStorage;
138148
}
139149

140150
/**
@@ -345,6 +355,8 @@ public function deleteById($customerId)
345355
$customerModel = $this->customerRegistry->retrieve($customerId);
346356
$customerModel->delete();
347357
$this->customerRegistry->remove($customerId);
358+
$this->notificationStorage->remove(NotificationStorage::UPDATE_CUSTOMER_SESSION, $customerId);
359+
348360
return true;
349361
}
350362

@@ -370,20 +382,4 @@ protected function addFilterGroupToCollection(
370382
$collection->addFieldToFilter($fields);
371383
}
372384
}
373-
374-
/**
375-
* Retrieve collection processor
376-
*
377-
* @deprecated 100.2.0
378-
* @return CollectionProcessorInterface
379-
*/
380-
private function getCollectionProcessor()
381-
{
382-
if (!$this->collectionProcessor) {
383-
$this->collectionProcessor = \Magento\Framework\App\ObjectManager::getInstance()->get(
384-
'Magento\Eav\Model\Api\SearchCriteria\CollectionProcessor'
385-
);
386-
}
387-
return $this->collectionProcessor;
388-
}
389385
}

0 commit comments

Comments
 (0)