Skip to content

Commit 93efd27

Browse files
author
Dmytro Voskoboinikov
committed
Merge branch '2.3-develop' into 2.3-bugfixes-220318
2 parents a287fd4 + 8088a14 commit 93efd27

File tree

42 files changed

+749
-191
lines changed

Some content is hidden

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

42 files changed

+749
-191
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ public function execute()
113113
$options
114114
);
115115
$valueOptions = (isset($options['value']) && is_array($options['value'])) ? $options['value'] : [];
116+
foreach (array_keys($valueOptions) as $key) {
117+
if (!empty($options['delete'][$key])) {
118+
unset($valueOptions[$key]);
119+
}
120+
}
116121
$this->checkEmptyOption($response, $valueOptions);
117122
}
118123

app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ protected function modifyPriceData($object, $data)
358358
{
359359
/** @var array $priceItem */
360360
foreach ($data as $key => $priceItem) {
361-
if (isset($priceItem['price']) && $priceItem['price'] > 0) {
361+
if (array_key_exists('price', $priceItem)) {
362362
$data[$key]['website_price'] = $priceItem['price'];
363363
}
364364
if ($priceItem['all_groups']) {

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/ValidateTest.php

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,20 @@ public function provideUniqueData()
249249
]
250250
], false
251251
],
252+
'empty and deleted' => [
253+
[
254+
'value' => [
255+
"option_0" => [1, 0],
256+
"option_1" => [2, 0],
257+
"option_2" => ["", ""],
258+
],
259+
'delete' => [
260+
"option_0" => "",
261+
"option_1" => "",
262+
"option_2" => "1",
263+
]
264+
], false
265+
],
252266
];
253267
}
254268

@@ -321,7 +335,34 @@ public function provideEmptyOption()
321335
(object) [
322336
'error' => false,
323337
]
324-
]
338+
],
339+
'empty admin scope options and deleted' => [
340+
[
341+
'value' => [
342+
"option_0" => [''],
343+
],
344+
'delete' => [
345+
'option_0' => '1',
346+
],
347+
],
348+
(object) [
349+
'error' => false,
350+
],
351+
],
352+
'empty admin scope options and not deleted' => [
353+
[
354+
'value' => [
355+
"option_0" => [''],
356+
],
357+
'delete' => [
358+
'option_0' => '0',
359+
],
360+
],
361+
(object) [
362+
'error' => true,
363+
'message' => 'The value of Admin scope can\'t be empty.',
364+
],
365+
],
325366
];
326367
}
327368
}

app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/TierpriceTest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ public function testSetPriceData()
141141
{
142142
$attributeName = 'tier_price';
143143
$tierPrices = [
144+
[
145+
'price' => 0,
146+
'all_groups' => 1,
147+
],
144148
[
145149
'price' => 10,
146150
'all_groups' => 1,
@@ -153,6 +157,12 @@ public function testSetPriceData()
153157
$productPrice = 20;
154158
$allCustomersGroupId = 32000;
155159
$finalTierPrices = [
160+
[
161+
'price' => 0,
162+
'all_groups' => 1,
163+
'website_price' => 0,
164+
'cust_group' => 32000,
165+
],
156166
[
157167
'price' => 10,
158168
'all_groups' => 1,
@@ -170,8 +180,11 @@ public function testSetPriceData()
170180
->disableOriginalConstructor()->getMock();
171181
$allCustomersGroup = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class)
172182
->disableOriginalConstructor()->getMock();
173-
$this->groupManagement->expects($this->once())->method('getAllCustomersGroup')->willReturn($allCustomersGroup);
174-
$allCustomersGroup->expects($this->once())->method('getId')->willReturn($allCustomersGroupId);
183+
$this->groupManagement
184+
->expects($this->exactly(2))
185+
->method('getAllCustomersGroup')
186+
->willReturn($allCustomersGroup);
187+
$allCustomersGroup->expects($this->exactly(2))->method('getId')->willReturn($allCustomersGroupId);
175188
$object->expects($this->once())->method('getPrice')->willReturn($productPrice);
176189
$this->attribute->expects($this->atLeastOnce())->method('isScopeGlobal')->willReturn(true);
177190
$object->expects($this->once())->method('getStoreId')->willReturn(null);

app/code/Magento/CatalogImportExport/Model/Indexer/Product/Flat/Plugin/Import.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,30 @@
55
*/
66
namespace Magento\CatalogImportExport\Model\Indexer\Product\Flat\Plugin;
77

8+
use Magento\Catalog\Model\Indexer\Product\Flat\State as FlatState;
9+
810
class Import
911
{
12+
/**
13+
* @var \Magento\Catalog\Model\Indexer\Product\Flat\State
14+
*/
15+
private $flatState;
16+
1017
/**
1118
* @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor
1219
*/
1320
protected $_productFlatIndexerProcessor;
1421

1522
/**
1623
* @param \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor
24+
* @param \Magento\Catalog\Model\Indexer\Product\Flat\State $flatState
1725
*/
18-
public function __construct(\Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor)
19-
{
26+
public function __construct(
27+
\Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor,
28+
FlatState $flatState
29+
) {
2030
$this->_productFlatIndexerProcessor = $productFlatIndexerProcessor;
31+
$this->flatState = $flatState;
2132
}
2233

2334
/**
@@ -31,7 +42,10 @@ public function __construct(\Magento\Catalog\Model\Indexer\Product\Flat\Processo
3142
*/
3243
public function afterImportSource(\Magento\ImportExport\Model\Import $subject, $import)
3344
{
34-
$this->_productFlatIndexerProcessor->markIndexerAsInvalid();
45+
if ($this->flatState->isFlatEnabled() && !$this->_productFlatIndexerProcessor->isIndexerScheduled()) {
46+
$this->_productFlatIndexerProcessor->markIndexerAsInvalid();
47+
}
48+
3549
return $import;
3650
}
3751
}

app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Flat/Plugin/ImportTest.php

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,79 @@
55
*/
66
namespace Magento\CatalogImportExport\Test\Unit\Model\Indexer\Product\Flat\Plugin;
77

8+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
9+
810
class ImportTest extends \PHPUnit\Framework\TestCase
911
{
10-
public function testAfterImportSource()
12+
/**
13+
* @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor|\PHPUnit_Framework_MockObject_MockObject
14+
*/
15+
private $processorMock;
16+
17+
/**
18+
* @var \Magento\CatalogImportExport\Model\Indexer\Product\Flat\Plugin\Import
19+
*/
20+
private $model;
21+
22+
/**
23+
* @var \Magento\Catalog\Model\Indexer\Product\Flat\State|\PHPUnit_Framework_MockObject_MockObject
24+
*/
25+
private $flatStateMock;
26+
27+
/**
28+
* @var \Magento\ImportExport\Model\Import|\PHPUnit_Framework_MockObject_MockObject
29+
*/
30+
private $subjectMock;
31+
32+
protected function setUp()
1133
{
12-
/**
13-
* @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor|
14-
* \PHPUnit_Framework_MockObject_MockObject $processorMock
15-
*/
16-
$processorMock = $this->createPartialMock(
17-
\Magento\Catalog\Model\Indexer\Product\Flat\Processor::class,
18-
['markIndexerAsInvalid']
34+
$this->processorMock = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Flat\Processor::class)
35+
->disableOriginalConstructor()
36+
->setMethods(['markIndexerAsInvalid', 'isIndexerScheduled'])
37+
->getMock();
38+
39+
$this->flatStateMock = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Flat\State::class)
40+
->disableOriginalConstructor()
41+
->setMethods(['isFlatEnabled'])
42+
->getMock();
43+
44+
$this->subjectMock = $this->getMockBuilder(\Magento\ImportExport\Model\Import::class)
45+
->disableOriginalConstructor()
46+
->getMock();
47+
48+
$this->model = (new ObjectManager($this))->getObject(
49+
\Magento\CatalogImportExport\Model\Indexer\Product\Flat\Plugin\Import::class,
50+
[
51+
'productFlatIndexerProcessor' => $this->processorMock,
52+
'flatState' => $this->flatStateMock
53+
]
1954
);
55+
}
2056

21-
$subjectMock = $this->createMock(\Magento\ImportExport\Model\Import::class);
22-
$processorMock->expects($this->once())->method('markIndexerAsInvalid');
57+
public function testAfterImportSourceWithFlatEnabledAndIndexerScheduledDisabled()
58+
{
59+
$this->flatStateMock->expects($this->once())->method('isFlatEnabled')->willReturn(true);
60+
$this->processorMock->expects($this->once())->method('isIndexerScheduled')->willReturn(false);
61+
$this->processorMock->expects($this->once())->method('markIndexerAsInvalid');
62+
$someData = [1, 2, 3];
63+
$this->assertEquals($someData, $this->model->afterImportSource($this->subjectMock, $someData));
64+
}
2365

66+
public function testAfterImportSourceWithFlatDisabledAndIndexerScheduledDisabled()
67+
{
68+
$this->flatStateMock->expects($this->once())->method('isFlatEnabled')->willReturn(false);
69+
$this->processorMock->expects($this->never())->method('isIndexerScheduled')->willReturn(false);
70+
$this->processorMock->expects($this->never())->method('markIndexerAsInvalid');
2471
$someData = [1, 2, 3];
72+
$this->assertEquals($someData, $this->model->afterImportSource($this->subjectMock, $someData));
73+
}
2574

26-
$model = new \Magento\CatalogImportExport\Model\Indexer\Product\Flat\Plugin\Import($processorMock);
27-
$this->assertEquals($someData, $model->afterImportSource($subjectMock, $someData));
75+
public function testAfterImportSourceWithFlatEnabledAndIndexerScheduledEnabled()
76+
{
77+
$this->flatStateMock->expects($this->once())->method('isFlatEnabled')->willReturn(true);
78+
$this->processorMock->expects($this->once())->method('isIndexerScheduled')->willReturn(true);
79+
$this->processorMock->expects($this->never())->method('markIndexerAsInvalid');
80+
$someData = [1, 2, 3];
81+
$this->assertEquals($someData, $this->model->afterImportSource($this->subjectMock, $someData));
2882
}
2983
}

app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,20 @@ define([
7272
output = {},
7373
streetObject;
7474

75+
$.each(addrs, function (key) {
76+
if (addrs.hasOwnProperty(key) && !$.isFunction(addrs[key])) {
77+
output[self.toUnderscore(key)] = addrs[key];
78+
}
79+
});
80+
7581
if ($.isArray(addrs.street)) {
7682
streetObject = {};
7783
addrs.street.forEach(function (value, index) {
7884
streetObject[index] = value;
7985
});
80-
addrs.street = streetObject;
86+
output.street = streetObject;
8187
}
8288

83-
$.each(addrs, function (key) {
84-
if (addrs.hasOwnProperty(key) && !$.isFunction(addrs[key])) {
85-
output[self.toUnderscore(key)] = addrs[key];
86-
}
87-
});
88-
8989
return output;
9090
},
9191

app/code/Magento/Cron/Model/ResourceModel/Schedule.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,14 @@ public function trySetJobUniqueStatusAtomic($scheduleId, $newStatus, $currentSta
6666
{
6767
$connection = $this->getConnection();
6868

69-
$match = $connection->quoteInto('existing.job_code = current.job_code AND existing.status = ?', $newStatus);
69+
// this condition added to avoid cron jobs locking after incorrect termination of running job
70+
$match = $connection->quoteInto(
71+
'existing.job_code = current.job_code ' .
72+
'AND (existing.executed_at > UTC_TIMESTAMP() - INTERVAL 1 DAY OR existing.executed_at IS NULL) ' .
73+
'AND existing.status = ?',
74+
$newStatus
75+
);
76+
7077
$selectIfUnlocked = $connection->select()
7178
->joinLeft(
7279
['existing' => $this->getTable('cron_schedule')],
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Cron\Setup;
8+
9+
use Magento\Framework\Setup\InstallSchemaInterface;
10+
use Magento\Framework\Setup\ModuleContextInterface;
11+
use Magento\Framework\Setup\SchemaSetupInterface;
12+
13+
/**
14+
* Cron recurring setup
15+
*/
16+
class Recurring implements InstallSchemaInterface
17+
{
18+
/**
19+
* @var \Magento\Cron\Model\ResourceModel\Schedule
20+
*/
21+
private $schedule;
22+
23+
/**
24+
* Recurring constructor.
25+
* @param \Magento\Cron\Model\ResourceModel\Schedule $schedule
26+
*/
27+
public function __construct(
28+
\Magento\Cron\Model\ResourceModel\Schedule $schedule
29+
) {
30+
$this->schedule = $schedule;
31+
}
32+
33+
/**
34+
* {@inheritdoc}
35+
*/
36+
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
37+
{
38+
$connection = $this->schedule->getConnection();
39+
$connection->update(
40+
$this->schedule->getMainTable(),
41+
[
42+
'status' => \Magento\Cron\Model\Schedule::STATUS_ERROR,
43+
'messages' => 'The job is terminated due to system upgrade'
44+
],
45+
$connection->quoteInto('status = ?', \Magento\Cron\Model\Schedule::STATUS_RUNNING)
46+
);
47+
}
48+
}

app/code/Magento/Quote/Model/QuoteManagement.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -411,17 +411,24 @@ public function submit(QuoteEntity $quote, $orderData = [])
411411
*/
412412
protected function resolveItems(QuoteEntity $quote)
413413
{
414-
$quoteItems = [];
415-
foreach ($quote->getAllItems() as $quoteItem) {
416-
/** @var \Magento\Quote\Model\ResourceModel\Quote\Item $quoteItem */
417-
$quoteItems[$quoteItem->getId()] = $quoteItem;
418-
}
419414
$orderItems = [];
420-
foreach ($quoteItems as $quoteItem) {
421-
$parentItem = (isset($orderItems[$quoteItem->getParentItemId()])) ?
422-
$orderItems[$quoteItem->getParentItemId()] : null;
423-
$orderItems[$quoteItem->getId()] =
424-
$this->quoteItemToOrderItem->convert($quoteItem, ['parent_item' => $parentItem]);
415+
foreach ($quote->getAllItems() as $quoteItem) {
416+
$itemId = $quoteItem->getId();
417+
418+
if (!empty($orderItems[$itemId])) {
419+
continue;
420+
}
421+
422+
$parentItemId = $quoteItem->getParentItemId();
423+
/** @var \Magento\Quote\Model\ResourceModel\Quote\Item $parentItem */
424+
if ($parentItemId && !isset($orderItems[$parentItemId])) {
425+
$orderItems[$parentItemId] = $this->quoteItemToOrderItem->convert(
426+
$quoteItem->getParentItem(),
427+
['parent_item' => null]
428+
);
429+
}
430+
$parentItem = isset($orderItems[$parentItemId]) ? $orderItems[$parentItemId] : null;
431+
$orderItems[$itemId] = $this->quoteItemToOrderItem->convert($quoteItem, ['parent_item' => $parentItem]);
425432
}
426433
return array_values($orderItems);
427434
}

0 commit comments

Comments
 (0)