Skip to content

Commit 5b8aabb

Browse files
committed
Merge branch 'stability_control' of github.com:magento-commerce/magento2ce into stability_control
2 parents e961180 + 9a8b135 commit 5b8aabb

File tree

21 files changed

+715
-63
lines changed

21 files changed

+715
-63
lines changed

app/code/Magento/AsynchronousOperations/Model/ResourceModel/System/Message/Collection/Synchronized/Plugin.php

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111
class Plugin
1212
{
13+
private const MESSAGES_LIMIT = 5;
1314
/**
1415
* @var \Magento\AdminNotification\Model\System\MessageFactory
1516
*/
@@ -95,27 +96,32 @@ public function afterToArray(
9596
$this->bulkNotificationManagement->getAcknowledgedBulksByUser($userId)
9697
);
9798
$bulkMessages = [];
99+
$messagesCount = 0;
100+
$data = [];
98101
foreach ($userBulks as $bulk) {
99102
$bulkUuid = $bulk->getBulkId();
100103
if (!in_array($bulkUuid, $acknowledgedBulks)) {
101-
$details = $this->operationDetails->getDetails($bulkUuid);
102-
$text = $this->getText($details);
103-
$bulkStatus = $this->statusMapper->operationStatusToBulkSummaryStatus($bulk->getStatus());
104-
if ($bulkStatus === \Magento\Framework\Bulk\BulkSummaryInterface::IN_PROGRESS) {
105-
$text = __('%1 item(s) are currently being updated.', $details['operations_total']) . $text;
104+
if ($messagesCount < self::MESSAGES_LIMIT) {
105+
$details = $this->operationDetails->getDetails($bulkUuid);
106+
$text = $this->getText($details);
107+
$bulkStatus = $this->statusMapper->operationStatusToBulkSummaryStatus($bulk->getStatus());
108+
if ($bulkStatus === \Magento\Framework\Bulk\BulkSummaryInterface::IN_PROGRESS) {
109+
$text = __('%1 item(s) are currently being updated.', $details['operations_total']) . $text;
110+
}
111+
$data = [
112+
'data' => [
113+
'text' => __('Task "%1": ', $bulk->getDescription()) . $text,
114+
'severity' => \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR,
115+
// md5() here is not for cryptographic use.
116+
// phpcs:ignore Magento2.Security.InsecureFunction
117+
'identity' => md5('bulk' . $bulkUuid),
118+
'uuid' => $bulkUuid,
119+
'status' => $bulkStatus,
120+
'created_at' => $bulk->getStartTime()
121+
]
122+
];
123+
$messagesCount++;
106124
}
107-
$data = [
108-
'data' => [
109-
'text' => __('Task "%1": ', $bulk->getDescription()) . $text,
110-
'severity' => \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR,
111-
// md5() here is not for cryptographic use.
112-
// phpcs:ignore Magento2.Security.InsecureFunction
113-
'identity' => md5('bulk' . $bulkUuid),
114-
'uuid' => $bulkUuid,
115-
'status' => $bulkStatus,
116-
'created_at' => $bulk->getStartTime()
117-
]
118-
];
119125
$bulkMessages[] = $this->messageFactory->create($data)->toArray();
120126
}
121127
}

app/code/Magento/AsynchronousOperations/Test/Unit/Model/ResourceModel/System/Message/Collection/Synchronized/PluginTest.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
*/
2828
class PluginTest extends TestCase
2929
{
30+
private const MESSAGES_LIMIT = 5;
3031
/**
3132
* @var Plugin
3233
*/
@@ -163,6 +164,60 @@ public function testAfterTo($operationDetails)
163164
$this->assertEquals(2, $result2['totalRecords']);
164165
}
165166

167+
/**
168+
* Tests that message building operations don't get called more than Plugin::MESSAGES_LIMIT times
169+
*
170+
* @return void
171+
*/
172+
public function testAfterToWithMessageLimit()
173+
{
174+
$result = ['items' =>[], 'totalRecords' => 1];
175+
$messagesCount = self::MESSAGES_LIMIT + 1;
176+
$userId = 1;
177+
$bulkUuid = 2;
178+
$bulkArray = [
179+
'status' => BulkSummaryInterface::NOT_STARTED
180+
];
181+
182+
$bulkMock = $this->getMockBuilder(BulkSummary::class)
183+
->addMethods(['getStatus'])
184+
->onlyMethods(['getBulkId', 'getDescription', 'getStartTime'])
185+
->disableOriginalConstructor()
186+
->getMock();
187+
$userBulks = array_fill(0, $messagesCount, $bulkMock);
188+
$bulkMock->expects($this->exactly($messagesCount))
189+
->method('getBulkId')->willReturn($bulkUuid);
190+
$this->operationsDetailsMock
191+
->expects($this->exactly(self::MESSAGES_LIMIT))
192+
->method('getDetails')
193+
->with($bulkUuid)
194+
->willReturn([
195+
'operations_successful' => 1,
196+
'operations_failed' => 0
197+
]);
198+
$bulkMock->expects($this->exactly(self::MESSAGES_LIMIT))
199+
->method('getDescription')->willReturn('Bulk Description');
200+
$this->messagefactoryMock->expects($this->exactly($messagesCount))
201+
->method('create')->willReturn($this->messageMock);
202+
$this->messageMock->expects($this->exactly($messagesCount))->method('toArray')->willReturn($bulkArray);
203+
$this->authorizationMock
204+
->expects($this->once())
205+
->method('isAllowed')
206+
->with($this->resourceName)
207+
->willReturn(true);
208+
$this->userContextMock->expects($this->once())->method('getUserId')->willReturn($userId);
209+
$this->bulkNotificationMock
210+
->expects($this->once())
211+
->method('getAcknowledgedBulksByUser')
212+
->with($userId)
213+
->willReturn([]);
214+
$this->statusMapper->expects($this->exactly(self::MESSAGES_LIMIT))
215+
->method('operationStatusToBulkSummaryStatus');
216+
$this->bulkStatusMock->expects($this->once())->method('getBulksByUser')->willReturn($userBulks);
217+
$result2 = $this->plugin->afterToArray($this->collectionMock, $result);
218+
$this->assertEquals($result['totalRecords'] + $messagesCount, $result2['totalRecords']);
219+
}
220+
166221
/**
167222
* @return array
168223
*/

app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Product.php

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,26 @@
1111
*/
1212
namespace Magento\Catalog\Block\Adminhtml\Category\Tab;
1313

14+
use Magento\Backend\Block\Template\Context;
1415
use Magento\Backend\Block\Widget\Grid;
1516
use Magento\Backend\Block\Widget\Grid\Column;
1617
use Magento\Backend\Block\Widget\Grid\Extended;
18+
use Magento\Backend\Helper\Data;
1719
use Magento\Catalog\Model\Product\Attribute\Source\Status;
1820
use Magento\Catalog\Model\Product\Visibility;
21+
use Magento\Catalog\Model\ProductFactory;
1922
use Magento\Framework\App\ObjectManager;
23+
use Magento\Framework\Registry;
2024

21-
class Product extends \Magento\Backend\Block\Widget\Grid\Extended
25+
class Product extends Extended
2226
{
2327
/**
24-
* Core registry
25-
*
26-
* @var \Magento\Framework\Registry
28+
* @var Registry
2729
*/
2830
protected $_coreRegistry = null;
2931

3032
/**
31-
* @var \Magento\Catalog\Model\ProductFactory
33+
* @var ProductFactory
3234
*/
3335
protected $_productFactory;
3436

@@ -43,19 +45,19 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended
4345
private $visibility;
4446

4547
/**
46-
* @param \Magento\Backend\Block\Template\Context $context
47-
* @param \Magento\Backend\Helper\Data $backendHelper
48-
* @param \Magento\Catalog\Model\ProductFactory $productFactory
49-
* @param \Magento\Framework\Registry $coreRegistry
48+
* @param Context $context
49+
* @param Data $backendHelper
50+
* @param ProductFactory $productFactory
51+
* @param Registry $coreRegistry
5052
* @param array $data
5153
* @param Visibility|null $visibility
5254
* @param Status|null $status
5355
*/
5456
public function __construct(
55-
\Magento\Backend\Block\Template\Context $context,
56-
\Magento\Backend\Helper\Data $backendHelper,
57-
\Magento\Catalog\Model\ProductFactory $productFactory,
58-
\Magento\Framework\Registry $coreRegistry,
57+
Context $context,
58+
Data $backendHelper,
59+
ProductFactory $productFactory,
60+
Registry $coreRegistry,
5961
array $data = [],
6062
Visibility $visibility = null,
6163
Status $status = null
@@ -68,6 +70,8 @@ public function __construct(
6870
}
6971

7072
/**
73+
* Initialize object
74+
*
7175
* @return void
7276
*/
7377
protected function _construct()
@@ -79,6 +83,8 @@ protected function _construct()
7983
}
8084

8185
/**
86+
* Get current category
87+
*
8288
* @return array|null
8389
*/
8490
public function getCategory()
@@ -87,6 +93,8 @@ public function getCategory()
8793
}
8894

8995
/**
96+
* Add column filter to collection
97+
*
9098
* @param Column $column
9199
* @return $this
92100
*/
@@ -110,6 +118,8 @@ protected function _addColumnFilterToCollection($column)
110118
}
111119

112120
/**
121+
* Prepare collection.
122+
*
113123
* @return Grid
114124
*/
115125
protected function _prepareCollection()
@@ -136,6 +146,7 @@ protected function _prepareCollection()
136146
'left'
137147
);
138148
$storeId = (int)$this->getRequest()->getParam('store', 0);
149+
$collection->setStoreId($storeId);
139150
if ($storeId > 0) {
140151
$collection->addStoreFilter($storeId);
141152
}
@@ -153,6 +164,8 @@ protected function _prepareCollection()
153164
}
154165

155166
/**
167+
* Prepare columns.
168+
*
156169
* @return Extended
157170
*/
158171
protected function _prepareColumns()
@@ -230,6 +243,8 @@ protected function _prepareColumns()
230243
}
231244

232245
/**
246+
* Retrieve grid reload url
247+
*
233248
* @return string
234249
*/
235250
public function getGridUrl()
@@ -238,6 +253,8 @@ public function getGridUrl()
238253
}
239254

240255
/**
256+
* Get selected products
257+
*
241258
* @return array
242259
*/
243260
protected function _getSelectedProducts()

app/code/Magento/CustomerImportExport/Model/Import/Customer.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
namespace Magento\CustomerImportExport\Model\Import;
99

1010
use Magento\Customer\Api\Data\CustomerInterface;
11-
use Magento\ImportExport\Model\Import;
12-
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
13-
use Magento\ImportExport\Model\Import\AbstractSource;
1411
use Magento\Customer\Model\Indexer\Processor;
1512
use Magento\Framework\App\ObjectManager;
13+
use Magento\ImportExport\Model\Import;
14+
use Magento\ImportExport\Model\Import\AbstractSource;
15+
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
1616

1717
/**
1818
* Customer entity import
@@ -162,6 +162,7 @@ class Customer extends AbstractCustomer
162162
'failures_num',
163163
'first_failure',
164164
'lock_expires',
165+
CustomerInterface::DISABLE_AUTO_GROUP_CHANGE,
165166
];
166167

167168
/**
@@ -413,7 +414,6 @@ protected function _prepareDataForUpdate(array $rowData)
413414
} else {
414415
$createdAt = (new \DateTime())->setTimestamp(strtotime($rowData['created_at']));
415416
}
416-
417417
$emailInLowercase = strtolower(trim($rowData[self::COLUMN_EMAIL]));
418418
$newCustomer = false;
419419
$entityId = $this->_getCustomerId($emailInLowercase, $rowData[self::COLUMN_WEBSITE]);
@@ -448,7 +448,6 @@ protected function _prepareDataForUpdate(array $rowData)
448448
$value = (new \DateTime())->setTimestamp(strtotime($value));
449449
$value = $value->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
450450
}
451-
452451
if (!$this->_attributes[$attributeCode]['is_static']) {
453452
/** @var $attribute \Magento\Customer\Model\Attribute */
454453
$attribute = $this->_customerModel->getAttribute($attributeCode);
@@ -488,9 +487,12 @@ protected function _prepareDataForUpdate(array $rowData)
488487
} else {
489488
$entityRow['store_id'] = $this->getCustomerStoreId($emailInLowercase, $rowData[self::COLUMN_WEBSITE]);
490489
}
490+
if (!empty($rowData[CustomerInterface::DISABLE_AUTO_GROUP_CHANGE])) {
491+
$entityRow[CustomerInterface::DISABLE_AUTO_GROUP_CHANGE] =
492+
$rowData[CustomerInterface::DISABLE_AUTO_GROUP_CHANGE];
493+
}
491494
$entitiesToUpdate[] = $entityRow;
492495
}
493-
494496
return [
495497
self::ENTITIES_TO_CREATE_KEY => $entitiesToCreate,
496498
self::ENTITIES_TO_UPDATE_KEY => $entitiesToUpdate,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,10 @@ public function isLast()
563563
{
564564
$items = $this->getAllItems();
565565
foreach ($items as $item) {
566+
if ($item->getOrderItem()->isDummy()) {
567+
continue;
568+
}
569+
566570
if (!$item->isLast()) {
567571
return false;
568572
}

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\Sales\Model\Order\Creditmemo\CommentFactory;
2121
use Magento\Sales\Model\Order\Creditmemo\Config;
2222
use Magento\Sales\Model\Order\Creditmemo\Item;
23+
use Magento\Sales\Model\Order\Item as OrderItem;
2324
use Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item\Collection as ItemCollection;
2425
use Magento\Sales\Model\ResourceModel\Order\Creditmemo\Item\CollectionFactory;
2526
use Magento\Store\Model\StoreManagerInterface;
@@ -201,4 +202,40 @@ public function testGetItemsCollectionWithoutId()
201202
$itemsCollection = $this->creditmemo->getItemsCollection();
202203
$this->assertEquals($items, $itemsCollection);
203204
}
205+
206+
public function testIsLastForLastCreditMemo(): void
207+
{
208+
$item = $this->getMockBuilder(Item::class)->disableOriginalConstructor()->getMock();
209+
$orderItem = $this->getMockBuilder(OrderItem::class)->disableOriginalConstructor()->getMock();
210+
$orderItem
211+
->expects($this->once())
212+
->method('isDummy')
213+
->willReturn(true);
214+
$item->expects($this->once())
215+
->method('getOrderItem')
216+
->willReturn($orderItem);
217+
$this->creditmemo->setItems([$item]);
218+
$this->assertTrue($this->creditmemo->isLast());
219+
}
220+
221+
public function testIsLastForNonLastCreditMemo(): void
222+
{
223+
$item = $this->getMockBuilder(Item::class)->disableOriginalConstructor()->getMock();
224+
$orderItem = $this->getMockBuilder(OrderItem::class)->disableOriginalConstructor()->getMock();
225+
$orderItem
226+
->expects($this->once())
227+
->method('isDummy')
228+
->willReturn(false);
229+
$item->expects($this->once())
230+
->method('getOrderItem')
231+
->willReturn($orderItem);
232+
$item->expects($this->once())
233+
->method('getOrderItem')
234+
->willReturn($orderItem);
235+
$item->expects($this->once())
236+
->method('isLast')
237+
->willReturn(false);
238+
$this->creditmemo->setItems([$item]);
239+
$this->assertFalse($this->creditmemo->isLast());
240+
}
204241
}

app/code/Magento/SalesRule/Model/Quote/Discount.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function collect(
158158
$address->setCartFixedRules([]);
159159
$quote->setCartFixedRules([]);
160160
foreach ($items as $item) {
161-
$this->rulesApplier->setAppliedRuleIds($item, []);
161+
$item->setAppliedRuleIds(null);
162162
if ($item->getExtensionAttributes()) {
163163
$item->getExtensionAttributes()->setDiscounts(null);
164164
}

0 commit comments

Comments
 (0)