Skip to content

Commit 91aaab5

Browse files
author
Joan He
committed
Merge remote-tracking branch 'upstream/2.3-develop' into MAGETWO-89776
2 parents 80f08d4 + 659c737 commit 91aaab5

File tree

49 files changed

+838
-58
lines changed

Some content is hidden

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

49 files changed

+838
-58
lines changed

app/code/Magento/Backend/Model/Widget/Grid/Parser.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ public function parseExpression($expression)
3030
$expression = trim($expression);
3131
foreach ($this->_operations as $operation) {
3232
$splittedExpr = preg_split('/\\' . $operation . '/', $expression, -1, PREG_SPLIT_DELIM_CAPTURE);
33-
if (count($splittedExpr) > 1) {
34-
for ($i = 0; $i < count($splittedExpr); $i++) {
33+
$count = count($splittedExpr);
34+
if ($count > 1) {
35+
for ($i = 0; $i < $count; $i++) {
3536
$stack = array_merge($stack, $this->parseExpression($splittedExpr[$i]));
3637
if ($i > 0) {
3738
$stack[] = $operation;

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,9 @@
159159
</argument>
160160
</arguments>
161161
</type>
162+
<type name="Magento\Framework\View\Layout\Generator\Block">
163+
<arguments>
164+
<argument name="defaultClass" xsi:type="string">Magento\Backend\Block\Template</argument>
165+
</arguments>
166+
</type>
162167
</config>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ProductCategoryFilter implements CustomFilterInterface
2121
*/
2222
public function apply(Filter $filter, AbstractDb $collection)
2323
{
24-
$conditionType = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
24+
$conditionType = $filter->getConditionType() ?: 'eq';
2525
$categoryFilter = [$conditionType => [$filter->getValue()]];
2626

2727
/** @var Collection $collection */

app/code/Magento/Catalog/Model/CategoryRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function save(\Magento\Catalog\Api\Data\CategoryInterface $category)
129129
*/
130130
public function get($categoryId, $storeId = null)
131131
{
132-
$cacheKey = null !== $storeId ? $storeId : 'all';
132+
$cacheKey = $storeId ?? 'all';
133133
if (!isset($this->instances[$categoryId][$cacheKey])) {
134134
/** @var Category $category */
135135
$category = $this->categoryFactory->create();

app/code/Magento/Catalog/Model/Layer/Filter/DataProvider/Price.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ public function getMaxPrice()
282282
public function getPriorFilters($filterParams)
283283
{
284284
$priorFilters = [];
285-
for ($i = 1; $i < count($filterParams); ++$i) {
285+
$count = count($filterParams);
286+
for ($i = 1; $i < $count; ++$i) {
286287
$priorFilter = $this->validateFilter($filterParams[$i]);
287288
if ($priorFilter) {
288289
$priorFilters[] = $priorFilter;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2006,7 +2006,7 @@ public function getIsVirtual()
20062006
*/
20072007
public function addCustomOption($code, $value, $product = null)
20082008
{
2009-
$product = $product ? $product : $this;
2009+
$product = $product ?: $this;
20102010
$option = $this->_itemOptionFactory->create()->addData(
20112011
['product_id' => $product->getId(), 'product' => $product, 'code' => $code, 'value' => $value]
20122012
);

app/code/Magento/Catalog/Model/Product/Option/Type/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function __construct(
127127
$this->mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
128128
$this->validatorInfo = $validatorInfo;
129129
$this->validatorFile = $validatorFile;
130-
$this->serializer = $serializer ? $serializer : ObjectManager::getInstance()->get(Json::class);
130+
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class);
131131
parent::__construct($checkoutSession, $scopeConfig, $data);
132132
}
133133

app/code/Magento/Catalog/Model/Product/ProductList/Toolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,6 @@ public function getLimit()
102102
public function getCurrentPage()
103103
{
104104
$page = (int) $this->request->getParam(self::PAGE_PARM_NAME);
105-
return $page ? $page : 1;
105+
return $page ?: 1;
106106
}
107107
}

app/code/Magento/Catalog/Model/Product/Type/Price.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public function getTierPrice($qty, $product)
341341
}
342342
}
343343

344-
return $prices ? $prices : [];
344+
return $prices ?: [];
345345
}
346346

347347
/**

app/code/Magento/Catalog/Model/ProductRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ protected function addFilterGroupToCollection(
740740
$fields = [];
741741
$categoryFilter = [];
742742
foreach ($filterGroup->getFilters() as $filter) {
743-
$conditionType = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
743+
$conditionType = $filter->getConditionType() ?: 'eq';
744744

745745
if ($filter->getField() == 'category_id') {
746746
$categoryFilter[$conditionType][] = $filter->getValue();

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
@@ -31,7 +31,7 @@ public function testApply()
3131
->disableOriginalConstructor()
3232
->getMock();
3333

34-
$filterMock->expects($this->exactly(2))
34+
$filterMock->expects($this->exactly(1))
3535
->method('getConditionType')
3636
->willReturn('condition');
3737
$filterMock->expects($this->once())

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ protected function setUp()
3838

3939
public function testEstimateRowSize()
4040
{
41-
$this->markTestSkipped('Unskip after MAGETWO-89738');
42-
$expectedValue = 2400000;
41+
$expectedValue = 4000000;
4342

4443
$this->websiteManagementMock->expects($this->once())->method('getCount')->willReturn(100);
4544
$collectionMock = $this->createMock(\Magento\Customer\Model\ResourceModel\Group\Collection::class);

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -414,28 +414,40 @@ public function getProductAttributes($storeId, array $productIds, array $attribu
414414
foreach ($attributeTypes as $backendType => $attributeIds) {
415415
if ($attributeIds) {
416416
$tableName = $this->getTable('catalog_product_entity_' . $backendType);
417-
$selects[] = $this->connection->select()->from(
418-
['t_default' => $tableName],
419-
[$linkField, 'attribute_id']
417+
418+
$select = $this->connection->select()->from(
419+
['t' => $tableName],
420+
[
421+
$linkField => 't.' . $linkField,
422+
'attribute_id' => 't.attribute_id',
423+
'value' => $this->unifyField($ifStoreValue, $backendType),
424+
]
420425
)->joinLeft(
421426
['t_store' => $tableName],
422427
$this->connection->quoteInto(
423-
't_default.' . $linkField . '=t_store.' . $linkField .
424-
' AND t_default.attribute_id=t_store.attribute_id' .
428+
't.' . $linkField . '=t_store.' . $linkField .
429+
' AND t.attribute_id=t_store.attribute_id' .
425430
' AND t_store.store_id = ?',
426431
$storeId
427432
),
428-
['value' => $this->unifyField($ifStoreValue, $backendType)]
429-
)->where(
430-
't_default.store_id = ?',
431-
0
433+
[]
434+
)->joinLeft(
435+
['t_default' => $tableName],
436+
$this->connection->quoteInto(
437+
't.' . $linkField . '=t_default.' . $linkField .
438+
' AND t.attribute_id=t_default.attribute_id' .
439+
' AND t_default.store_id = ?',
440+
0
441+
),
442+
[]
432443
)->where(
433-
't_default.attribute_id IN (?)',
444+
't.attribute_id IN (?)',
434445
$attributeIds
435446
)->where(
436-
't_default.' . $linkField . ' IN (?)',
447+
't.' . $linkField . ' IN (?)',
437448
array_keys($productLinkFieldsToEntityIdMap)
438-
);
449+
)->distinct();
450+
$selects[] = $select;
439451
}
440452
}
441453

app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/MapperTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ public function testGetDependenciesWhenDependentIsInvisible($isValueSatisfy)
9898
{
9999
$expected = [];
100100
$rowData = array_values($this->_testData);
101-
for ($i = 0; $i < count($this->_testData); ++$i) {
101+
$count = count($this->_testData);
102+
for ($i = 0; $i < $count; ++$i) {
102103
$data = $rowData[$i];
103104
$dependentPath = 'some path ' . $i;
104105
$field = $this->_getField(
@@ -158,7 +159,8 @@ public function testGetDependenciesIsVisible()
158159
{
159160
$expected = [];
160161
$rowData = array_values($this->_testData);
161-
for ($i = 0; $i < count($this->_testData); ++$i) {
162+
$count = count($this->_testData);
163+
for ($i = 0; $i < $count; ++$i) {
162164
$data = $rowData[$i];
163165
$field = $this->_getField(
164166
true,

app/code/Magento/Paypal/Model/Report/Settlement.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ public function parseCsv($localCsv, $format = 'new')
369369
// Section columns.
370370
// In case ever the column order is changed, we will have the items recorded properly
371371
// anyway. We have named, not numbered columns.
372-
for ($i = 1; $i < count($line); $i++) {
372+
$count = count($line);
373+
for ($i = 1; $i < $count; $i++) {
373374
$sectionColumns[$line[$i]] = $i;
374375
}
375376
$flippedSectionColumns = array_flip($sectionColumns);

app/code/Magento/Review/view/frontend/web/js/process-reviews.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ define([
5050

5151
$(function () {
5252
$('.product-info-main .reviews-actions a').click(function (event) {
53-
var acnchor;
53+
var anchor;
5454

5555
event.preventDefault();
56-
acnchor = $(this).attr('href').replace(/^.*?(#|$)/, '');
56+
anchor = $(this).attr('href').replace(/^.*?(#|$)/, '');
5757
$('.product.data.items [data-role="content"]').each(function (index) { //eslint-disable-line
5858
if (this.id == 'reviews') { //eslint-disable-line eqeqeq
5959
$('.product.data.items').tabs('activate', index);
6060
$('html, body').animate({
61-
scrollTop: $('#' + acnchor).offset().top - 50
61+
scrollTop: $('#' + anchor).offset().top - 50
6262
}, 300);
6363
}
6464
});

app/code/Magento/Sales/Model/Order/Item.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function getQtyToShip()
233233
public function getSimpleQtyToShip()
234234
{
235235
$qty = $this->getQtyOrdered() - $this->getQtyShipped() - $this->getQtyRefunded() - $this->getQtyCanceled();
236-
return max($qty, 0);
236+
return max(round($qty, 8), 0);
237237
}
238238

239239
/**
@@ -248,7 +248,7 @@ public function getQtyToInvoice()
248248
}
249249

250250
$qty = $this->getQtyOrdered() - $this->getQtyInvoiced() - $this->getQtyCanceled();
251-
return max($qty, 0);
251+
return max(round($qty, 8), 0);
252252
}
253253

254254
/**

app/code/Magento/Sales/Test/Unit/Model/Order/ItemTest.php

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,114 @@ public function getProductOptionsDataProvider()
235235
]
236236
];
237237
}
238+
239+
/**
240+
* Test different combinations of item qty setups
241+
*
242+
* @param array $options
243+
* @param float $expectedResult
244+
*
245+
* @dataProvider getItemQtyVariants
246+
*/
247+
public function testGetSimpleQtyToMethods(array $options, $expectedResult)
248+
{
249+
$this->model->setData($options);
250+
$this->assertSame($this->model->getSimpleQtyToShip(), $expectedResult['to_ship']);
251+
$this->assertSame($this->model->getQtyToInvoice(), $expectedResult['to_invoice']);
252+
}
253+
254+
/**
255+
* Provides different combinations of qty options for an item and the
256+
* expected qtys pending shipment and invoice
257+
*
258+
* @return array
259+
*/
260+
public function getItemQtyVariants()
261+
{
262+
return [
263+
'empty_item' => [
264+
'options' => [
265+
'qty_ordered' => 0, 'qty_invoiced' => 0, 'qty_refunded' => 0, 'qty_shipped' => 0,
266+
'qty_canceled' => 0
267+
],
268+
'expectedResult' => ['to_ship' => 0.0, 'to_invoice' => 0.0]
269+
],
270+
'ordered_item' => [
271+
'options' => [
272+
'qty_ordered' => 12, 'qty_invoiced' => 0, 'qty_refunded' => 0, 'qty_shipped' => 0,
273+
'qty_canceled' => 0
274+
],
275+
'expectedResult' => ['to_ship' => 12.0, 'to_invoice' => 12.0]
276+
],
277+
'partially_invoiced' => [
278+
'options' => ['qty_ordered' => 12, 'qty_invoiced' => 4, 'qty_refunded' => 0, 'qty_shipped' => 0,
279+
'qty_canceled' => 0,
280+
],
281+
'expectedResult' => ['to_ship' => 12.0, 'to_invoice' => 8.0]
282+
],
283+
'completely_invoiced' => [
284+
'options' => [
285+
'qty_ordered' => 12, 'qty_invoiced' => 12, 'qty_refunded' => 0, 'qty_shipped' => 0,
286+
'qty_canceled' => 0,
287+
],
288+
'expectedResult' => ['to_ship' => 12.0, 'to_invoice' => 0.0]
289+
],
290+
'partially_invoiced_refunded' => [
291+
'options' => [
292+
'qty_ordered' => 12, 'qty_invoiced' => 5, 'qty_refunded' => 5, 'qty_shipped' => 0,
293+
'qty_canceled' => 0,
294+
],
295+
'expectedResult' => ['to_ship' => 7.0, 'to_invoice' => 7.0]
296+
],
297+
'partially_refunded' => [
298+
'options' => [
299+
'qty_ordered' => 12, 'qty_invoiced' => 12, 'qty_refunded' => 5, 'qty_shipped' => 0,
300+
'qty_canceled' => 0,
301+
],
302+
'expectedResult' => ['to_ship' => 7.0, 'to_invoice' => 0.0]
303+
],
304+
'partially_shipped' => [
305+
'options' => [
306+
'qty_ordered' => 12, 'qty_invoiced' => 0, 'qty_refunded' => 0, 'qty_shipped' => 4,
307+
'qty_canceled' => 0
308+
],
309+
'expectedResult' => ['to_ship' => 8.0, 'to_invoice' => 12.0]
310+
],
311+
'partially_refunded_partially_shipped' => [
312+
'options' => [
313+
'qty_ordered' => 12, 'qty_invoiced' => 12, 'qty_refunded' => 5, 'qty_shipped' => 4,
314+
'qty_canceled' => 0
315+
],
316+
'expectedResult' => ['to_ship' => 3.0, 'to_invoice' => 0.0]
317+
],
318+
'complete' => [
319+
'options' => [
320+
'qty_ordered' => 12, 'qty_invoiced' => 12, 'qty_refunded' => 0, 'qty_shipped' => 12,
321+
'qty_canceled' => 0
322+
],
323+
'expectedResult' => ['to_ship' => 0.0, 'to_invoice' => 0.0]
324+
],
325+
'canceled' => [
326+
'options' => [
327+
'qty_ordered' => 12, 'qty_invoiced' => 0, 'qty_refunded' => 0, 'qty_shipped' => 0,
328+
'qty_canceled' => 12
329+
],
330+
'expectedResult' => ['to_ship' => 0.0, 'to_invoice' => 0.0]
331+
],
332+
'completely_shipped_using_decimals' => [
333+
'options' => [
334+
'qty_ordered' => 4.4, 'qty_invoiced' => 0.4, 'qty_refunded' => 0.4, 'qty_shipped' => 4,
335+
'qty_canceled' => 0,
336+
],
337+
'expectedResult' => ['to_ship' => 0.0, 'to_invoice' => 4.0]
338+
],
339+
'completely_invoiced_using_decimals' => [
340+
'options' => [
341+
'qty_ordered' => 4.4, 'qty_invoiced' => 4, 'qty_refunded' => 0, 'qty_shipped' => 4,
342+
'qty_canceled' => 0.4
343+
],
344+
'expectedResult' => ['to_ship' => 0.0, 'to_invoice' => 0.0]
345+
]
346+
];
347+
}
238348
}

app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected function _initRule()
7474
/**
7575
* Initiate action
7676
*
77-
* @return this
77+
* @return $this
7878
*/
7979
protected function _initAction()
8080
{

app/code/Magento/Security/Model/AdminSessionInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function isOtherSessionsTerminated()
164164
* Setter for isOtherSessionsTerminated
165165
*
166166
* @param bool $isOtherSessionsTerminated
167-
* @return this
167+
* @return $this
168168
* @since 100.1.0
169169
*/
170170
public function setIsOtherSessionsTerminated($isOtherSessionsTerminated)

app/code/Magento/Usps/Model/Carrier.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2054,7 +2054,8 @@ protected function _parseZip($zipString, $returnFull = false)
20542054
if (preg_match('/[\\d\\w]{5}\\-[\\d\\w]{4}/', $zipString) != 0) {
20552055
$zip = explode('-', $zipString);
20562056
}
2057-
for ($i = 0; $i < count($zip); ++$i) {
2057+
$count = count($zip);
2058+
for ($i = 0; $i < $count; ++$i) {
20582059
if (strlen($zip[$i]) == 5) {
20592060
$zip5 = $zip[$i];
20602061
} elseif (strlen($zip[$i]) == 4) {

app/code/Magento/Webapi/Model/Rest/Swagger/Generator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,8 @@ private function handlePrimitive($name, $prefix)
749749
private function convertPathParams($uri)
750750
{
751751
$parts = explode('/', $uri);
752-
for ($i=0; $i < count($parts); $i++) {
752+
$count = count($parts);
753+
for ($i=0; $i < $count; $i++) {
753754
if (strpos($parts[$i], ':') === 0) {
754755
$parts[$i] = '{' . substr($parts[$i], 1) . '}';
755756
}

app/code/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategy.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ public function addAnnotation(\DOMElement $element, $documentation, $default = n
229229
$this->_processElementType($elementType, $documentation, $appInfoNode);
230230

231231
if (preg_match_all('/{([a-z]+):(.+)}/Ui', $documentation, $matches)) {
232-
for ($i = 0; $i < count($matches[0]); $i++) {
232+
$count = count($matches[0]);
233+
for ($i = 0; $i < $count; $i++) {
233234
$appinfoTag = $matches[0][$i];
234235
$tagName = $matches[1][$i];
235236
$tagValue = $matches[2][$i];

0 commit comments

Comments
 (0)