Skip to content

Commit ca56c0a

Browse files
committed
Merge remote-tracking branch 'mainline/2.2-develop' into MAGETWO-64085
2 parents 9de3b46 + fd81f51 commit ca56c0a

File tree

247 files changed

+9297
-2082
lines changed

Some content is hidden

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

247 files changed

+9297
-2082
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,22 @@ public function getFormKey()
8585
*
8686
* @param string $moduleName Full module name
8787
* @return boolean
88-
* @deprecated 100.2.0 Magento does not support custom disabling/enabling module output since 2.2.0 version
89-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
88+
* @deprecated 100.2.0 Magento does not support disabling/enabling modules output from the Admin Panel since 2.2.0
89+
* version. Module output can still be enabled/disabled in configuration files. However, this functionality should
90+
* not be used in future development. Module design should explicitly state dependencies to avoid requiring output
91+
* disabling. This functionality will temporarily be kept in Magento core, as there are unresolved modularity
92+
* issues that will be addressed in future releases.
9093
*/
9194
public function isOutputEnabled($moduleName = null)
9295
{
93-
return true;
96+
if ($moduleName === null) {
97+
$moduleName = $this->getModuleName();
98+
}
99+
100+
return !$this->_scopeConfig->isSetFlag(
101+
'advanced/modules_disable_output/' . $moduleName,
102+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
103+
);
94104
}
95105

96106
/**

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@
160160
<argument name="estimators" xsi:type="array">
161161
<item name="bundle" xsi:type="object">Magento\Catalog\Model\Indexer\Price\CompositeProductBatchSizeManagement</item>
162162
</argument>
163+
<argument name="batchSizeAdjusters" xsi:type="array">
164+
<item name="bundle" xsi:type="object">Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductBatchSizeAdjuster</item>
165+
</argument>
163166
</arguments>
164167
</type>
165168
<type name="Magento\Bundle\Model\ResourceModel\Indexer\Price">

app/code/Magento/Bundle/view/adminhtml/web/js/bundle-type-handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5-
/*jshint browser:true jquery:true expr:true*/
5+
66
define([
77
'jquery',
88
'Magento_Catalog/catalog/type-events',

app/code/Magento/Bundle/view/frontend/web/js/float.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
/**
77
* @api
8+
* @deprecated since version 2.2.0
89
*/
910
define([
1011
'jquery',

app/code/Magento/Captcha/view/frontend/web/onepage.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* See COPYING.txt for license details.
44
*/
55

6+
/**
7+
* @deprecated since version 2.2.0
8+
*/
69
define(['jquery'], function ($) {
710
'use strict';
811

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ public function execute($ids = null)
106106
$this->_defaultIndexerResource->getMainTable()
107107
);
108108

109+
// Prepare replica table for indexation.
110+
$this->_defaultIndexerResource->getConnection()->truncateTable($replicaTable);
111+
109112
/** @var \Magento\Catalog\Model\ResourceModel\Product\Indexer\AbstractIndexer $indexer */
110113
foreach ($this->getTypeIndexers() as $indexer) {
111114
$indexer->getTableStrategy()->setUseIdxTable(false);

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/BatchSizeCalculator.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,24 @@ class BatchSizeCalculator
2121
*/
2222
private $estimators;
2323

24+
/**
25+
* @var \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductBatchSizeAdjusterInterface[]
26+
* @since 2.2.0
27+
*/
28+
private $batchSizeAdjusters;
29+
2430
/**
2531
* BatchSizeCalculator constructor.
2632
* @param array $batchRowsCount
2733
* @param array $estimators
34+
* @param array $batchSizeAdjusters
35+
* @since 2.2.0
2836
*/
29-
public function __construct(array $batchRowsCount, array $estimators)
37+
public function __construct(array $batchRowsCount, array $estimators, array $batchSizeAdjusters)
3038
{
3139
$this->batchRowsCount = $batchRowsCount;
3240
$this->estimators = $estimators;
41+
$this->batchSizeAdjusters = $batchSizeAdjusters;
3342
}
3443

3544
/**
@@ -52,6 +61,10 @@ public function estimateBatchSize(\Magento\Framework\DB\Adapter\AdapterInterface
5261
? $this->estimators[$indexerTypeId]
5362
: $this->estimators['default'];
5463

64+
$batchRowsCount = isset($this->batchSizeAdjusters[$indexerTypeId])
65+
? $this->batchSizeAdjusters[$indexerTypeId]->adjust($batchRowsCount)
66+
: $batchRowsCount;
67+
5568
$calculator->ensureBatchSize($connection, $batchRowsCount);
5669

5770
return $batchRowsCount;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price;
8+
9+
/**
10+
* Correct batch size according to number of composite related items.
11+
*/
12+
class CompositeProductBatchSizeAdjuster implements CompositeProductBatchSizeAdjusterInterface
13+
{
14+
/**
15+
* @var CompositeProductRelationsCalculator
16+
*/
17+
private $compositeProductRelationsCalculator;
18+
19+
/**
20+
* @param CompositeProductRelationsCalculator $compositeProductRelationsCalculator
21+
*/
22+
public function __construct(CompositeProductRelationsCalculator $compositeProductRelationsCalculator)
23+
{
24+
$this->compositeProductRelationsCalculator = $compositeProductRelationsCalculator;
25+
}
26+
27+
/**
28+
* {@inheritdoc}
29+
*/
30+
public function adjust($batchSize)
31+
{
32+
$maxRelationsCount = $this->compositeProductRelationsCalculator->getMaxRelationsCount();
33+
return $maxRelationsCount > 0 ? ceil($batchSize / $maxRelationsCount) : $batchSize;
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price;
8+
9+
/**
10+
* Correct batch size according to number of composite related items.
11+
* @api
12+
*/
13+
interface CompositeProductBatchSizeAdjusterInterface
14+
{
15+
/**
16+
* Correct batch size according to number of composite related items.
17+
*
18+
* @param int $batchSize
19+
* @return int
20+
*/
21+
public function adjust($batchSize);
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Price;
8+
9+
/**
10+
* Class calculates composite product relations.
11+
*/
12+
class CompositeProductRelationsCalculator
13+
{
14+
/**
15+
* @param DefaultPrice $indexerResource
16+
*/
17+
public function __construct(DefaultPrice $indexerResource)
18+
{
19+
$this->indexerResource = $indexerResource;
20+
}
21+
22+
/**
23+
* Returns maximum number of composite related products.
24+
*
25+
* @return int
26+
*/
27+
public function getMaxRelationsCount()
28+
{
29+
$connection = $this->indexerResource->getConnection();
30+
$relationSelect = $connection->select();
31+
$relationSelect->from(
32+
['relation' => $this->indexerResource->getTable('catalog_product_relation')],
33+
['count' => new \Zend_Db_Expr('count(relation.child_id)')]
34+
);
35+
$relationSelect->group('parent_id');
36+
37+
$maxSelect = $connection->select();
38+
$maxSelect->from(
39+
['max_value' => $relationSelect],
40+
['count' => new \Zend_Db_Expr('MAX(count)')]
41+
);
42+
return $connection->fetchOne($maxSelect);
43+
}
44+
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CompositeProductRowSizeEstimator.php

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ class CompositeProductRowSizeEstimator implements IndexTableRowSizeEstimatorInte
2020
*/
2121
const MEMORY_SIZE_FOR_ONE_ROW = 200;
2222

23-
/**
24-
* @var DefaultPrice
25-
*/
26-
private $indexerResource;
27-
2823
/**
2924
* @var WebsiteManagementInterface
3025
*/
@@ -36,18 +31,25 @@ class CompositeProductRowSizeEstimator implements IndexTableRowSizeEstimatorInte
3631
private $collectionFactory;
3732

3833
/**
39-
* @param DefaultPrice $indexerResource
34+
* @var CompositeProductRelationsCalculator
35+
* @since 2.2.0
36+
*/
37+
private $compositeProductRelationsCalculator;
38+
39+
/**
4040
* @param WebsiteManagementInterface $websiteManagement
4141
* @param CollectionFactory $collectionFactory
42+
* @param CompositeProductRelationsCalculator $compositeProductRelationsCalculator
43+
* @since 2.2.0
4244
*/
4345
public function __construct(
44-
DefaultPrice $indexerResource,
4546
WebsiteManagementInterface $websiteManagement,
46-
CollectionFactory $collectionFactory
47+
CollectionFactory $collectionFactory,
48+
CompositeProductRelationsCalculator $compositeProductRelationsCalculator
4749
) {
48-
$this->indexerResource = $indexerResource;
4950
$this->websiteManagement = $websiteManagement;
5051
$this->collectionFactory = $collectionFactory;
52+
$this->compositeProductRelationsCalculator = $compositeProductRelationsCalculator;
5153
}
5254

5355
/**
@@ -59,21 +61,7 @@ public function estimateRowSize()
5961
{
6062
$websitesCount = $this->websiteManagement->getCount();
6163
$customerGroupCount = $this->collectionFactory->create()->getSize();
62-
63-
$connection = $this->indexerResource->getConnection();
64-
$relationSelect = $connection->select();
65-
$relationSelect->from(
66-
['relation' => $this->indexerResource->getTable('catalog_product_relation')],
67-
['count' => new \Zend_Db_Expr('count(relation.child_id)')]
68-
);
69-
$relationSelect->group('parent_id');
70-
71-
$maxSelect = $connection->select();
72-
$maxSelect->from(
73-
['max_value' => $relationSelect],
74-
['count' => new \Zend_Db_Expr('MAX(count)')]
75-
);
76-
$maxRelatedProductCount = $connection->fetchOne($maxSelect);
64+
$maxRelatedProductCount = $this->compositeProductRelationsCalculator->getMaxRelationsCount();
7765

7866
/**
7967
* Calculate memory size for largest composite product in database.

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ public function testToHtml()
5858
->getMock();
5959
$eventManager->expects($this->exactly(2))->method('dispatch')->will($this->returnValue(true));
6060

61+
$scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config::class)
62+
->setMethods(['getValue'])
63+
->disableOriginalConstructor()->getMock();
64+
$scopeConfig->expects($this->once())->method('getValue')->withAnyParameters()
65+
->will($this->returnValue(false));
66+
6167
$product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor()
6268
->setMethods(['setStoreId', 'load', 'getId', '__wakeup', '__sleep'])
6369
->getMock();
@@ -90,6 +96,8 @@ public function testToHtml()
9096

9197
$this->context->expects($this->once())->method('getEventManager')
9298
->will($this->returnValue($eventManager));
99+
$this->context->expects($this->once())->method('getScopeConfig')
100+
->will($this->returnValue($scopeConfig));
93101
$this->context->expects($this->once())->method('getLayout')
94102
->will($this->returnValue($layout));
95103
$this->context->expects($this->once())->method('getRequest')

app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ protected function generalGetProductCollection()
186186
{
187187
$this->eventManager->expects($this->exactly(2))->method('dispatch')
188188
->will($this->returnValue(true));
189+
$this->scopeConfig->expects($this->once())->method('getValue')->withAnyParameters()
190+
->willReturn(false);
189191
$this->cacheState->expects($this->atLeastOnce())->method('isEnabled')->withAnyParameters()
190192
->willReturn(false);
191193
$this->catalogConfig->expects($this->once())->method('getProductAttributes')

app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/Indexer/Price/BatchSizeCalculatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ protected function setUp()
2929
$this->batchRowsCount = 200;
3030
$this->model = new \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator(
3131
['default' => $this->batchRowsCount],
32-
['default' => $this->estimatorMock]
32+
['default' => $this->estimatorMock],
33+
[]
3334
);
3435
}
3536

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Unit\Model\ResourceModel\Product\Indexer\Price;
8+
9+
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductBatchSizeAdjuster;
10+
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductRelationsCalculator;
11+
12+
class CompositeProductBatchSizeAdjusterTest extends \PHPUnit\Framework\TestCase
13+
{
14+
/**
15+
* @var CompositeProductBatchSizeAdjuster
16+
*/
17+
private $model;
18+
19+
/**
20+
* @var \PHPUnit_Framework_MockObject_MockObject|CompositeProductRelationsCalculator
21+
*/
22+
private $relationsCalculatorMock;
23+
24+
protected function setUp()
25+
{
26+
$this->relationsCalculatorMock = $this->getMockBuilder(CompositeProductRelationsCalculator::class)
27+
->disableOriginalConstructor()
28+
->getMock();
29+
$this->model = new CompositeProductBatchSizeAdjuster($this->relationsCalculatorMock);
30+
}
31+
32+
public function testAdjust()
33+
{
34+
$this->relationsCalculatorMock->expects($this->once())
35+
->method('getMaxRelationsCount')
36+
->willReturn(200);
37+
$this->assertEquals(25, $this->model->adjust(5000));
38+
}
39+
}

0 commit comments

Comments
 (0)