Skip to content

Commit 59e6196

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into MAGETWO-73989
2 parents 28bc70d + 1e230b1 commit 59e6196

File tree

94 files changed

+2508
-748
lines changed

Some content is hidden

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

94 files changed

+2508
-748
lines changed

app/code/Magento/Backup/etc/adminhtml/system.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,22 @@
2626
<label>Scheduled Backup Type</label>
2727
<depends>
2828
<field id="enabled">1</field>
29+
<field id="functionality_enabled">1</field>
2930
</depends>
3031
<source_model>Magento\Backup\Model\Config\Source\Type</source_model>
3132
</field>
3233
<field id="time" translate="label" type="time" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
3334
<label>Start Time</label>
3435
<depends>
3536
<field id="enabled">1</field>
37+
<field id="functionality_enabled">1</field>
3638
</depends>
3739
</field>
3840
<field id="frequency" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
3941
<label>Frequency</label>
4042
<depends>
4143
<field id="enabled">1</field>
44+
<field id="functionality_enabled">1</field>
4245
</depends>
4346
<source_model>Magento\Cron\Model\Config\Source\Frequency</source_model>
4447
<backend_model>Magento\Backup\Model\Config\Backend\Cron</backend_model>
@@ -48,6 +51,7 @@
4851
<comment>Please put your store into maintenance mode during backup.</comment>
4952
<depends>
5053
<field id="enabled">1</field>
54+
<field id="functionality_enabled">1</field>
5155
</depends>
5256
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
5357
</field>

app/code/Magento/Braintree/Controller/Paypal/PlaceOrder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function execute()
7474
$this->logger->critical($e);
7575
$this->messageManager->addExceptionMessage(
7676
$e,
77-
'The order #' . $quote->getReservedOrderId() . ' cannot be processed.'
77+
__('The order #%1 cannot be processed.', $quote->getReservedOrderId())
7878
);
7979
}
8080

app/code/Magento/Catalog/Api/Data/CategoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function setParentId($parentId);
4343
/**
4444
* Get category name
4545
*
46-
* @return string
46+
* @return string|null
4747
*/
4848
public function getName();
4949

app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Full.php

Lines changed: 73 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,41 @@
55
*/
66
namespace Magento\Catalog\Model\Indexer\Category\Product\Action;
77

8+
use Magento\Catalog\Api\Data\ProductInterface;
9+
use Magento\Catalog\Model\Config;
10+
use Magento\Catalog\Model\Indexer\Category\Product\AbstractAction;
811
use Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher;
12+
use Magento\Framework\App\ObjectManager;
13+
use Magento\Framework\DB\Adapter\AdapterInterface;
914
use Magento\Framework\DB\Query\Generator as QueryGenerator;
1015
use Magento\Framework\App\ResourceConnection;
16+
use Magento\Framework\DB\Select;
17+
use Magento\Framework\EntityManager\MetadataPool;
18+
use Magento\Framework\Indexer\BatchProviderInterface;
19+
use Magento\Framework\Indexer\BatchSizeManagementInterface;
1120
use Magento\Indexer\Model\ProcessManager;
21+
use Magento\Store\Model\Store;
22+
use Magento\Store\Model\StoreManagerInterface;
1223

1324
/**
1425
* Class Full reindex action
1526
*
16-
* @package Magento\Catalog\Model\Indexer\Category\Product\Action
1727
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1828
*/
19-
class Full extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractAction
29+
class Full extends AbstractAction
2030
{
2131
/**
22-
* @var \Magento\Framework\Indexer\BatchSizeManagementInterface
32+
* @var BatchSizeManagementInterface
2333
*/
2434
private $batchSizeManagement;
2535

2636
/**
27-
* @var \Magento\Framework\Indexer\BatchProviderInterface
37+
* @var BatchProviderInterface
2838
*/
2939
private $batchProvider;
3040

3141
/**
32-
* @var \Magento\Framework\EntityManager\MetadataPool
42+
* @var MetadataPool
3343
*/
3444
protected $metadataPool;
3545

@@ -52,25 +62,25 @@ class Full extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractActio
5262

5363
/**
5464
* @param ResourceConnection $resource
55-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
56-
* @param \Magento\Catalog\Model\Config $config
65+
* @param StoreManagerInterface $storeManager
66+
* @param Config $config
5767
* @param QueryGenerator|null $queryGenerator
58-
* @param \Magento\Framework\Indexer\BatchSizeManagementInterface|null $batchSizeManagement
59-
* @param \Magento\Framework\Indexer\BatchProviderInterface|null $batchProvider
60-
* @param \Magento\Framework\EntityManager\MetadataPool|null $metadataPool
68+
* @param BatchSizeManagementInterface|null $batchSizeManagement
69+
* @param BatchProviderInterface|null $batchProvider
70+
* @param MetadataPool|null $metadataPool
6171
* @param int|null $batchRowsCount
6272
* @param ActiveTableSwitcher|null $activeTableSwitcher
6373
* @param ProcessManager $processManager
6474
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
6575
*/
6676
public function __construct(
67-
\Magento\Framework\App\ResourceConnection $resource,
68-
\Magento\Store\Model\StoreManagerInterface $storeManager,
69-
\Magento\Catalog\Model\Config $config,
77+
ResourceConnection $resource,
78+
StoreManagerInterface $storeManager,
79+
Config $config,
7080
QueryGenerator $queryGenerator = null,
71-
\Magento\Framework\Indexer\BatchSizeManagementInterface $batchSizeManagement = null,
72-
\Magento\Framework\Indexer\BatchProviderInterface $batchProvider = null,
73-
\Magento\Framework\EntityManager\MetadataPool $metadataPool = null,
81+
BatchSizeManagementInterface $batchSizeManagement = null,
82+
BatchProviderInterface $batchProvider = null,
83+
MetadataPool $metadataPool = null,
7484
$batchRowsCount = null,
7585
ActiveTableSwitcher $activeTableSwitcher = null,
7686
ProcessManager $processManager = null
@@ -81,64 +91,69 @@ public function __construct(
8191
$config,
8292
$queryGenerator
8393
);
84-
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
94+
$objectManager = ObjectManager::getInstance();
8595
$this->batchSizeManagement = $batchSizeManagement ?: $objectManager->get(
86-
\Magento\Framework\Indexer\BatchSizeManagementInterface::class
96+
BatchSizeManagementInterface::class
8797
);
8898
$this->batchProvider = $batchProvider ?: $objectManager->get(
89-
\Magento\Framework\Indexer\BatchProviderInterface::class
99+
BatchProviderInterface::class
90100
);
91101
$this->metadataPool = $metadataPool ?: $objectManager->get(
92-
\Magento\Framework\EntityManager\MetadataPool::class
102+
MetadataPool::class
93103
);
94104
$this->batchRowsCount = $batchRowsCount;
95105
$this->activeTableSwitcher = $activeTableSwitcher ?: $objectManager->get(ActiveTableSwitcher::class);
96106
$this->processManager = $processManager ?: $objectManager->get(ProcessManager::class);
97107
}
98108

99109
/**
110+
* Create the store tables
111+
*
100112
* @return void
101113
*/
102114
private function createTables()
103115
{
104116
foreach ($this->storeManager->getStores() as $store) {
105-
$this->tableMaintainer->createTablesForStore($store->getId());
117+
$this->tableMaintainer->createTablesForStore((int)$store->getId());
106118
}
107119
}
108120

109121
/**
122+
* Truncates the replica tables
123+
*
110124
* @return void
111125
*/
112126
private function clearReplicaTables()
113127
{
114128
foreach ($this->storeManager->getStores() as $store) {
115-
$this->connection->truncateTable($this->tableMaintainer->getMainReplicaTable($store->getId()));
129+
$this->connection->truncateTable($this->tableMaintainer->getMainReplicaTable((int)$store->getId()));
116130
}
117131
}
118132

119133
/**
134+
* Switches the active table
135+
*
120136
* @return void
121137
*/
122138
private function switchTables()
123139
{
124140
$tablesToSwitch = [];
125141
foreach ($this->storeManager->getStores() as $store) {
126-
$tablesToSwitch[] = $this->tableMaintainer->getMainTable($store->getId());
142+
$tablesToSwitch[] = $this->tableMaintainer->getMainTable((int)$store->getId());
127143
}
128144
$this->activeTableSwitcher->switchTable($this->connection, $tablesToSwitch);
129145
}
130146

131147
/**
132-
* Refresh entities index
133-
*
134-
* @return $this
148+
* @inheritdoc
135149
*/
136150
public function execute()
137151
{
138152
$this->createTables();
139153
$this->clearReplicaTables();
140154
$this->reindex();
141155
$this->switchTables();
156+
142157
return $this;
143158
}
144159

@@ -165,7 +180,7 @@ protected function reindex()
165180
/**
166181
* Execute indexation by store
167182
*
168-
* @param \Magento\Store\Model\Store $store
183+
* @param Store $store
169184
*/
170185
private function reindexStore($store)
171186
{
@@ -177,31 +192,31 @@ private function reindexStore($store)
177192
/**
178193
* Publish data from tmp to replica table
179194
*
180-
* @param \Magento\Store\Model\Store $store
195+
* @param Store $store
181196
* @return void
182197
*/
183198
private function publishData($store)
184199
{
185-
$select = $this->connection->select()->from($this->tableMaintainer->getMainTmpTable($store->getId()));
200+
$select = $this->connection->select()->from($this->tableMaintainer->getMainTmpTable((int)$store->getId()));
186201
$columns = array_keys(
187-
$this->connection->describeTable($this->tableMaintainer->getMainReplicaTable($store->getId()))
202+
$this->connection->describeTable($this->tableMaintainer->getMainReplicaTable((int)$store->getId()))
188203
);
189-
$tableName = $this->tableMaintainer->getMainReplicaTable($store->getId());
204+
$tableName = $this->tableMaintainer->getMainReplicaTable((int)$store->getId());
190205

191206
$this->connection->query(
192207
$this->connection->insertFromSelect(
193208
$select,
194209
$tableName,
195210
$columns,
196-
\Magento\Framework\DB\Adapter\AdapterInterface::INSERT_ON_DUPLICATE
211+
AdapterInterface::INSERT_ON_DUPLICATE
197212
)
198213
);
199214
}
200215

201216
/**
202-
* {@inheritdoc}
217+
* @inheritdoc
203218
*/
204-
protected function reindexRootCategory(\Magento\Store\Model\Store $store)
219+
protected function reindexRootCategory(Store $store)
205220
{
206221
if ($this->isIndexRootCategoryNeeded()) {
207222
$this->reindexCategoriesBySelect($this->getAllProducts($store), 'cp.entity_id IN (?)', $store);
@@ -211,62 +226,64 @@ protected function reindexRootCategory(\Magento\Store\Model\Store $store)
211226
/**
212227
* Reindex products of anchor categories
213228
*
214-
* @param \Magento\Store\Model\Store $store
229+
* @param Store $store
215230
* @return void
216231
*/
217-
protected function reindexAnchorCategories(\Magento\Store\Model\Store $store)
232+
protected function reindexAnchorCategories(Store $store)
218233
{
219234
$this->reindexCategoriesBySelect($this->getAnchorCategoriesSelect($store), 'ccp.product_id IN (?)', $store);
220235
}
221236

222237
/**
223238
* Reindex products of non anchor categories
224239
*
225-
* @param \Magento\Store\Model\Store $store
240+
* @param Store $store
226241
* @return void
227242
*/
228-
protected function reindexNonAnchorCategories(\Magento\Store\Model\Store $store)
243+
protected function reindexNonAnchorCategories(Store $store)
229244
{
230245
$this->reindexCategoriesBySelect($this->getNonAnchorCategoriesSelect($store), 'ccp.product_id IN (?)', $store);
231246
}
232247

233248
/**
234249
* Reindex categories using given SQL select and condition.
235250
*
236-
* @param \Magento\Framework\DB\Select $basicSelect
251+
* @param Select $basicSelect
237252
* @param string $whereCondition
238-
* @param \Magento\Store\Model\Store $store
253+
* @param Store $store
239254
* @return void
240255
*/
241-
private function reindexCategoriesBySelect(\Magento\Framework\DB\Select $basicSelect, $whereCondition, $store)
256+
private function reindexCategoriesBySelect(Select $basicSelect, $whereCondition, $store)
242257
{
243-
$this->tableMaintainer->createMainTmpTable($store->getId());
258+
$this->tableMaintainer->createMainTmpTable((int)$store->getId());
244259

245-
$entityMetadata = $this->metadataPool->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class);
260+
$entityMetadata = $this->metadataPool->getMetadata(ProductInterface::class);
246261
$columns = array_keys(
247-
$this->connection->describeTable($this->tableMaintainer->getMainTmpTable($store->getId()))
262+
$this->connection->describeTable($this->tableMaintainer->getMainTmpTable((int)$store->getId()))
248263
);
249264
$this->batchSizeManagement->ensureBatchSize($this->connection, $this->batchRowsCount);
250-
$batches = $this->batchProvider->getBatches(
251-
$this->connection,
252-
$entityMetadata->getEntityTable(),
265+
266+
$select = $this->connection->select();
267+
$select->distinct(true);
268+
$select->from(['e' => $entityMetadata->getEntityTable()], $entityMetadata->getIdentifierField());
269+
270+
$batchQueries = $this->prepareSelectsByRange(
271+
$select,
253272
$entityMetadata->getIdentifierField(),
254-
$this->batchRowsCount
273+
(int)$this->batchRowsCount
255274
);
256-
foreach ($batches as $batch) {
257-
$this->connection->delete($this->tableMaintainer->getMainTmpTable($store->getId()));
275+
276+
foreach ($batchQueries as $query) {
277+
$this->connection->delete($this->tableMaintainer->getMainTmpTable((int)$store->getId()));
278+
$entityIds = $this->connection->fetchCol($query);
258279
$resultSelect = clone $basicSelect;
259-
$select = $this->connection->select();
260-
$select->distinct(true);
261-
$select->from(['e' => $entityMetadata->getEntityTable()], $entityMetadata->getIdentifierField());
262-
$entityIds = $this->batchProvider->getBatchIds($this->connection, $select, $batch);
263280
$resultSelect->where($whereCondition, $entityIds);
264281
$this->connection->query(
265282
$this->connection->insertFromSelect(
266283
$resultSelect,
267-
$this->tableMaintainer->getMainTmpTable($store->getId()),
284+
$this->tableMaintainer->getMainTmpTable((int)$store->getId()),
268285
$columns,
269-
\Magento\Framework\DB\Adapter\AdapterInterface::INSERT_ON_DUPLICATE
286+
AdapterInterface::INSERT_ON_DUPLICATE
270287
)
271288
);
272289
$this->publishData($store);

0 commit comments

Comments
 (0)