Skip to content

Commit 2cafb7a

Browse files
author
Oleksandr Iegorov
committed
Merge branch '2.2-develop' of github.com:magento/magento2ce into MAGETWO-81901
2 parents b1456cf + 8389f7a commit 2cafb7a

File tree

58 files changed

+756
-198
lines changed

Some content is hidden

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

58 files changed

+756
-198
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/magento/magento2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
44
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/magento-2/localized.png)](https://crowdin.com/project/magento-2)
55
<h2>Welcome</h2>
6-
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting edge, feature-rich eCommerce solution that gets results.
6+
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting-edge, feature-rich eCommerce solution that gets results.
77

88
## Magento system requirements
99
[Magento system requirements](http://devdocs.magento.com/guides/v2.2/install-gde/system-requirements2.html)

app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Radio.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public function getCondition()
3131
{
3232
if ($this->getValue()) {
3333
return $this->getColumn()->getValue();
34-
} else {
35-
return [['neq' => $this->getColumn()->getValue()], ['is' => new \Zend_Db_Expr('NULL')]];
3634
}
35+
return [['neq' => $this->getColumn()->getValue()], ['is' => new \Zend_Db_Expr('NULL')]];
3736
}
3837
}

app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,8 @@ public function getSelectedJson()
222222
if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
223223
$selected = explode(',', $selected);
224224
return join(',', $selected);
225-
} else {
226-
return '';
227225
}
226+
return '';
228227
}
229228

230229
/**
@@ -237,9 +236,8 @@ public function getSelected()
237236
if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
238237
$selected = explode(',', $selected);
239238
return $selected;
240-
} else {
241-
return [];
242239
}
240+
return [];
243241
}
244242

245243
/**

app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,8 @@ public function getSelectedJson()
218218
if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
219219
$selected = explode(',', $selected);
220220
return join(',', $selected);
221-
} else {
222-
return '';
223221
}
222+
return '';
224223
}
225224

226225
/**
@@ -233,9 +232,8 @@ public function getSelected()
233232
if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
234233
$selected = explode(',', $selected);
235234
return $selected;
236-
} else {
237-
return [];
238235
}
236+
return [];
239237
}
240238

241239
/**

app/code/Magento/Backend/Controller/Adminhtml/Auth/Login.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ public function execute()
5050
// redirect according to rewrite rule
5151
if ($requestUrl != $backendUrl) {
5252
return $this->getRedirect($backendUrl);
53-
} else {
54-
return $this->resultPageFactory->create();
5553
}
54+
return $this->resultPageFactory->create();
5655
}
5756

5857
/**

app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ private function getSecurityCookie()
3232
{
3333
if (!($this->securityCookie instanceof SecurityCookie)) {
3434
return \Magento\Framework\App\ObjectManager::getInstance()->get(SecurityCookie::class);
35-
} else {
36-
return $this->securityCookie;
3735
}
36+
return $this->securityCookie;
3837
}
3938

4039
/**

app/code/Magento/Backend/Model/Menu/Item.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,11 @@ public function populateFromArray(array $data)
503503
$this->_tooltip = $this->_getArgument($data, 'toolTip');
504504
$this->_title = $this->_getArgument($data, 'title');
505505
$this->target = $this->_getArgument($data, 'target');
506+
$this->_submenu = null;
506507
if (isset($data['sub_menu'])) {
507508
$menu = $this->_menuFactory->create();
508509
$menu->populateFromArray($data['sub_menu']);
509510
$this->_submenu = $menu;
510-
} else {
511-
$this->_submenu = null;
512511
}
513512
}
514513
}

app/code/Magento/Braintree/Test/Unit/Model/Report/BraintreeTransactionStub.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ public function __get($name)
3434
{
3535
if (array_key_exists($name, $this->_attributes)) {
3636
return $this->_attributes[$name];
37-
} else {
38-
trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
39-
return null;
4037
}
38+
trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
39+
return null;
4140
}
4241

4342
/**

app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ public function getChildren($item)
9595

9696
if (isset($itemsArray[$item->getOrderItem()->getId()])) {
9797
return $itemsArray[$item->getOrderItem()->getId()];
98-
} else {
99-
return null;
10098
}
99+
return null;
101100
}
102101

103102
/**
@@ -219,9 +218,8 @@ public function getOrderItem()
219218
{
220219
if ($this->getItem() instanceof \Magento\Sales\Model\Order\Item) {
221220
return $this->getItem();
222-
} else {
223-
return $this->getItem()->getOrderItem();
224221
}
222+
return $this->getItem()->getOrderItem();
225223
}
226224

227225
/**

app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,8 @@ public function isSelected($selection)
191191
return in_array($selection->getSelectionId(), $selectedOptions);
192192
} elseif ($selectedOptions == 'None') {
193193
return false;
194-
} else {
195-
return $selection->getIsDefault() && $selection->isSaleable();
196194
}
195+
return $selection->getIsDefault() && $selection->isSaleable();
197196
}
198197

199198
/**

app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,8 @@ public function getValueHtml($item)
142142
if ($attributes = $this->getSelectionAttributes($item)) {
143143
return sprintf('%d', $attributes['qty']) . ' x ' . $this->escapeHtml($item->getName()) . " "
144144
. $this->getOrder()->formatPrice($attributes['price']);
145-
} else {
146-
return $this->escapeHtml($item->getName());
147145
}
146+
return $this->escapeHtml($item->getName());
148147
}
149148

150149
/**
@@ -179,9 +178,8 @@ public function getChildren($item)
179178

180179
if (isset($itemsArray[$item->getOrderItem()->getId()])) {
181180
return $itemsArray[$item->getOrderItem()->getId()];
182-
} else {
183-
return null;
184181
}
182+
return null;
185183
}
186184

187185
/**

app/code/Magento/Bundle/Model/Plugin/PriceBackend.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ public function aroundValidate(
2929
&& $object->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC
3030
) {
3131
return true;
32-
} else {
33-
return $proceed($object);
3432
}
33+
return $proceed($object);
3534
}
3635
}

app/code/Magento/Bundle/Model/Product/Type.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,9 +1015,8 @@ public function shakeSelections($firstItem, $secondItem)
10151015
];
10161016
if ($aPosition == $bPosition) {
10171017
return 0;
1018-
} else {
1019-
return $aPosition < $bPosition ? -1 : 1;
10201018
}
1019+
return $aPosition < $bPosition ? -1 : 1;
10211020
}
10221021

10231022
/**

app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/AbstractItems.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ public function getChildren($item)
9292

9393
if (isset($itemsArray[$item->getOrderItem()->getId()])) {
9494
return $itemsArray[$item->getOrderItem()->getId()];
95-
} else {
96-
return null;
9795
}
96+
return null;
9897
}
9998

10099
/**
@@ -244,9 +243,8 @@ public function getOrderItem()
244243
{
245244
if ($this->getItem() instanceof \Magento\Sales\Model\Order\Item) {
246245
return $this->getItem();
247-
} else {
248-
return $this->getItem()->getOrderItem();
249246
}
247+
return $this->getItem()->getOrderItem();
250248
}
251249

252250
/**

app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,8 @@ public function calculateBundleAmount($basePriceValue, $bundleProduct, $selectio
271271
{
272272
if ($bundleProduct->getPriceType() == Price::PRICE_TYPE_FIXED) {
273273
return $this->calculateFixedBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude);
274-
} else {
275-
return $this->calculateDynamicBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude);
276274
}
275+
return $this->calculateDynamicBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude);
277276
}
278277

279278
/**

app/code/Magento/Bundle/Pricing/Price/BundleSelectionPrice.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ public function getProduct()
184184
{
185185
if ($this->bundleProduct->getPriceType() == Price::PRICE_TYPE_DYNAMIC) {
186186
return parent::getProduct();
187-
} else {
188-
return $this->bundleProduct;
189187
}
188+
return $this->bundleProduct;
190189
}
191190
}

app/code/Magento/Bundle/Pricing/Price/ConfiguredPrice.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,8 @@ public function getValue()
144144
$this->priceInfo
145145
->getPrice(BundleDiscountPrice::PRICE_CODE)
146146
->calculateDiscount($configuredOptionsAmount);
147-
} else {
148-
return parent::getValue();
149147
}
148+
return parent::getValue();
150149
}
151150

152151
/**

app/code/Magento/Catalog/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/ProductCategoryFilter.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ class ProductCategoryFilter implements CustomFilterInterface
2121
*/
2222
public function apply(Filter $filter, AbstractDb $collection)
2323
{
24-
$conditionType = $filter->getConditionType() ?: 'eq';
25-
$categoryFilter = [$conditionType => [$filter->getValue()]];
24+
$value = $filter->getValue();
25+
$conditionType = $filter->getConditionType() ?: 'in';
26+
if (($conditionType === 'in' || $conditionType === 'nin') && is_string($value)) {
27+
$value = explode(',', $value);
28+
} else {
29+
$value = [$value];
30+
}
31+
$categoryFilter = [$conditionType => $value];
2632

2733
/** @var Collection $collection */
2834
$collection->addCategoriesFilter($categoryFilter);
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
namespace Magento\Catalog\Model\Indexer\Category\Product\Plugin;
8+
9+
use Magento\Framework\App\ResourceConnection;
10+
use Magento\Store\Model\StoreManagerInterface;
11+
use Magento\Framework\Indexer\ScopeResolver\IndexScopeResolver;
12+
use Magento\Catalog\Model\Indexer\Category\Product\AbstractAction;
13+
use Magento\Framework\Search\Request\Dimension;
14+
15+
/**
16+
* Class that replace catalog_category_product_index table name on the table name segmented per store
17+
*/
18+
class TableResolver
19+
{
20+
/**
21+
* @var StoreManagerInterface
22+
*/
23+
private $storeManager;
24+
25+
/**
26+
* @var IndexScopeResolver
27+
*/
28+
private $tableResolver;
29+
30+
/**
31+
* @param StoreManagerInterface $storeManager
32+
* @param IndexScopeResolver $tableResolver
33+
*/
34+
public function __construct(
35+
StoreManagerInterface $storeManager,
36+
IndexScopeResolver $tableResolver
37+
) {
38+
$this->storeManager = $storeManager;
39+
$this->tableResolver = $tableResolver;
40+
}
41+
42+
/**
43+
* replacing catalog_category_product_index table name on the table name segmented per store
44+
*
45+
* @param ResourceConnection $subject
46+
* @param string $result
47+
* @param string|string[] $modelEntity
48+
*
49+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
50+
*
51+
* @return string
52+
*/
53+
public function afterGetTableName(
54+
\Magento\Framework\App\ResourceConnection $subject,
55+
string $result,
56+
$modelEntity
57+
) {
58+
if (!is_array($modelEntity) && $modelEntity === AbstractAction::MAIN_INDEX_TABLE) {
59+
$catalogCategoryProductDimension = new Dimension(
60+
\Magento\Store\Model\Store::ENTITY,
61+
$this->storeManager->getStore()->getId()
62+
);
63+
64+
$tableName = $this->tableResolver->resolve(
65+
AbstractAction::MAIN_INDEX_TABLE,
66+
[
67+
$catalogCategoryProductDimension
68+
]
69+
);
70+
return $tableName;
71+
}
72+
return $result;
73+
}
74+
}

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,19 @@ public function getMainTable(int $storeId)
136136
public function createTablesForStore(int $storeId)
137137
{
138138
$mainTableName = $this->getMainTable($storeId);
139-
$this->createTable($this->getTable(AbstractAction::MAIN_INDEX_TABLE), $mainTableName);
139+
//Create index table for store based on on main replica table
140+
//Using main replica table is necessary for backward capability and TableResolver plugin work
141+
$this->createTable(
142+
$this->getTable(AbstractAction::MAIN_INDEX_TABLE . $this->additionalTableSuffix),
143+
$mainTableName
144+
);
140145

141146
$mainReplicaTableName = $this->getMainTable($storeId) . $this->additionalTableSuffix;
142-
$this->createTable($this->getTable(AbstractAction::MAIN_INDEX_TABLE), $mainReplicaTableName);
147+
//Create replica table for store based on main replica table
148+
$this->createTable(
149+
$this->getTable(AbstractAction::MAIN_INDEX_TABLE . $this->additionalTableSuffix),
150+
$mainReplicaTableName
151+
);
143152
}
144153

145154
/**

app/code/Magento/Catalog/Model/ResourceModel/Attribute.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,15 @@ public function deleteEntity(\Magento\Framework\Model\AbstractModel $object)
141141
->getMetadata(ProductInterface::class)
142142
->getLinkField();
143143

144-
$select = $this->getConnection()->select()->from(
145-
$attribute->getEntity()->getEntityTable(),
146-
$linkField
147-
)->where(
148-
'attribute_set_id = ?',
149-
$result['attribute_set_id']
150-
);
151-
152-
$clearCondition = [
153-
'attribute_id =?' => $attribute->getId(),
154-
$linkField . ' IN (?)' => $select,
155-
];
156-
$this->getConnection()->delete($backendTable, $clearCondition);
144+
$select = $this->getConnection()->select()
145+
->from(['b' => $backendTable])
146+
->join(
147+
['e' => $attribute->getEntity()->getEntityTable()],
148+
"b.$linkField = e.$linkField"
149+
)->where('b.attribute_id = ?', $attribute->getId())
150+
->where('e.attribute_set_id = ?', $result['attribute_set_id']);
151+
152+
$this->getConnection()->query($select->deleteFromSelect('b'));
157153
}
158154
}
159155

app/code/Magento/Catalog/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/ProductCategoryFilterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testApplyWithoutCondition()
6666

6767
$collectionMock->expects($this->once())
6868
->method('addCategoriesFilter')
69-
->with(['eq' => ['value']]);
69+
->with(['in' => ['value']]);
7070

7171
$this->assertTrue($this->model->apply($filterMock, $collectionMock));
7272
}

0 commit comments

Comments
 (0)