Skip to content

Commit 3a73641

Browse files
author
Oleksii Korshenko
authored
Merge pull request #1690 from magento-engcom/2.1-develop-prs
Public Pull Requests #12115 Fix issue with special characters in email subject by @ihor-sviziev #11739 [Backport 2.1-develop] Remove hardcoding for Magento_Backend::admin in ACL tree by @navarr #11596 Fix issue #10032 - Download back-up .tgz always takes the latest that's created (2.1-develop) by @PieterCappelle #11631 Fixed order items list for order printing by @rogyar #11432 FIX #11022 in 2.1-develop: Filter Groups of search criteria parameter have not been included for further processing by @davidverholen Fixed Public Issues #6597 Sales email subject "&" turns to #8094 Special characters in store name converted to numerical character references in email subject #10032 Download back-up .tgz always takes the latest that's created #9830 Null order in Magento\Sales\Block\Order\PrintShipment.php #10530 Print order error on magento 2.1.8 #11022 GET v1/products/attribute-sets/sets/list inconsistent return result
2 parents 3d9a21c + 49f1c8f commit 3a73641

File tree

14 files changed

+128
-73
lines changed

14 files changed

+128
-73
lines changed

app/code/Magento/Backup/Model/BackupFactory.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,16 @@ public function __construct(\Magento\Framework\ObjectManagerInterface $objectMan
3535
*/
3636
public function create($timestamp, $type)
3737
{
38-
$backupId = $timestamp . '_' . $type;
3938
$fsCollection = $this->_objectManager->get('Magento\Backup\Model\Fs\Collection');
4039
$backupInstance = $this->_objectManager->get('Magento\Backup\Model\Backup');
40+
4141
foreach ($fsCollection as $backup) {
42-
if ($backup->getId() == $backupId) {
43-
$backupInstance->setType(
44-
$backup->getType()
45-
)->setTime(
46-
$backup->getTime()
47-
)->setName(
48-
$backup->getName()
49-
)->setPath(
50-
$backup->getPath()
51-
);
42+
if ($backup->getTime() === (int) $timestamp && $backup->getType() === $type) {
43+
$backupInstance->setData(['id' => $backup->getId()])
44+
->setType($backup->getType())
45+
->setTime($backup->getTime())
46+
->setName($backup->getName())
47+
->setPath($backup->getPath());
5248
break;
5349
}
5450
}

app/code/Magento/Backup/Test/Unit/Model/BackupFactoryTest.php

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -77,42 +77,29 @@ protected function setUp()
7777

7878
public function testCreate()
7979
{
80-
$this->_backupModel->expects(
81-
$this->once()
82-
)->method(
83-
'setType'
84-
)->with(
85-
$this->_data['type']
86-
)->will(
87-
$this->returnSelf()
88-
);
89-
$this->_backupModel->expects(
90-
$this->once()
91-
)->method(
92-
'setTime'
93-
)->with(
94-
$this->_data['time']
95-
)->will(
96-
$this->returnSelf()
97-
);
98-
$this->_backupModel->expects(
99-
$this->once()
100-
)->method(
101-
'setName'
102-
)->with(
103-
$this->_data['name']
104-
)->will(
105-
$this->returnSelf()
106-
);
107-
$this->_backupModel->expects(
108-
$this->once()
109-
)->method(
110-
'setPath'
111-
)->with(
112-
$this->_data['path']
113-
)->will(
114-
$this->returnSelf()
115-
);
80+
$this->_backupModel->expects($this->once())
81+
->method('setType')
82+
->with($this->_data['type'])
83+
->will($this->returnSelf());
84+
85+
$this->_backupModel->expects($this->once())
86+
->method('setTime')
87+
->with($this->_data['time'])
88+
->will($this->returnSelf());
89+
90+
$this->_backupModel->expects($this->once())
91+
->method('setName')
92+
->with($this->_data['name'])
93+
->will($this->returnSelf());
94+
95+
$this->_backupModel->expects($this->once())
96+
->method('setPath')
97+
->with($this->_data['path'])
98+
->will($this->returnSelf());
99+
100+
$this->_backupModel->expects($this->once())
101+
->method('setData')
102+
->will($this->returnSelf());
116103

117104
$this->_instance->create('1385661590', 'snapshot');
118105
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public function save(\Magento\Eav\Api\Data\AttributeSetInterface $attributeSet)
6262
*/
6363
public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
6464
{
65+
$this->searchCriteriaBuilder->setFilterGroups((array)$searchCriteria->getFilterGroups());
6566
$this->searchCriteriaBuilder->addFilters(
6667
[
6768
$this->filterBuilder
@@ -71,9 +72,15 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
7172
->create(),
7273
]
7374
);
75+
76+
$this->searchCriteriaBuilder->setSortOrders((array)$searchCriteria->getSortOrders());
7477
$this->searchCriteriaBuilder->setCurrentPage($searchCriteria->getCurrentPage());
7578
$this->searchCriteriaBuilder->setPageSize($searchCriteria->getPageSize());
76-
return $this->attributeSetRepository->getList($this->searchCriteriaBuilder->create());
79+
80+
$searchResult = $this->attributeSetRepository->getList($this->searchCriteriaBuilder->create());
81+
$searchResult->setSearchCriteria($searchCriteria);
82+
83+
return $searchResult;
7784
}
7885

7986
/**

app/code/Magento/Eav/Model/AttributeSetRepository.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
105105
$collection->setEntityTypeFilter($this->eavConfig->getEntityType($entityTypeCode)->getId());
106106
}
107107

108+
foreach ($searchCriteria->getFilterGroups() as $group) {
109+
$this->addFilterGroupToCollection($group, $collection);
110+
}
111+
108112
$collection->setCurPage($searchCriteria->getCurrentPage());
109113
$collection->setPageSize($searchCriteria->getPageSize());
110114

@@ -115,6 +119,29 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
115119
return $searchResults;
116120
}
117121

122+
/**
123+
* Helper function that adds a FilterGroup to the collection.
124+
*
125+
* @deprecated already removed in 2.2-develop. Use CollectionProcessorInterface to process search criteria
126+
*
127+
* @param \Magento\Framework\Api\Search\FilterGroup $filterGroup
128+
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection $collection
129+
* @return void
130+
*/
131+
private function addFilterGroupToCollection(
132+
\Magento\Framework\Api\Search\FilterGroup $filterGroup,
133+
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection $collection
134+
) {
135+
foreach ($filterGroup->getFilters() as $filter) {
136+
/** entity type filter is already set on collection */
137+
if ($filter->getField() === 'entity_type_code') {
138+
continue;
139+
}
140+
$conditionType = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
141+
$collection->addFieldToFilter($filter->getField(), [$conditionType, $filter->getValue()]);
142+
}
143+
}
144+
118145
/**
119146
* Retrieve entity type code from search criteria
120147
*

app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,12 @@ public function testGetList()
212212
$searchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteriaInterface');
213213

214214
$filterGroupMock = $this->getMock('\Magento\Framework\Api\Search\FilterGroup', [], [], '', false);
215-
$searchCriteriaMock->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroupMock]);
215+
$searchCriteriaMock->expects($this->exactly(2))->method('getFilterGroups')->willReturn([$filterGroupMock]);
216216

217217
$filterMock = $this->getMock('\Magento\Framework\Api\Filter', [], [], '', false);
218-
$filterGroupMock->expects($this->once())->method('getFilters')->willReturn([$filterMock]);
218+
$filterGroupMock->expects($this->exactly(2))->method('getFilters')->willReturn([$filterMock]);
219219

220-
$filterMock->expects($this->once())->method('getField')->willReturn('entity_type_code');
220+
$filterMock->expects($this->exactly(2))->method('getField')->willReturn('entity_type_code');
221221
$filterMock->expects($this->once())->method('getValue')->willReturn($entityTypeCode);
222222

223223
$collectionMock = $this->getMock(
@@ -273,7 +273,7 @@ public function testGetList()
273273
public function testGetListIfEntityTypeCodeIsNull()
274274
{
275275
$searchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteriaInterface');
276-
$searchCriteriaMock->expects($this->once())->method('getFilterGroups')->willReturn([]);
276+
$searchCriteriaMock->expects($this->exactly(2))->method('getFilterGroups')->willReturn([]);
277277

278278
$collectionMock = $this->getMock(
279279
'\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection',

app/code/Magento/Integration/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ public function isEverythingAllowed()
148148
public function getResourcesTreeJson()
149149
{
150150
$resources = $this->_resourceProvider->getAclResources();
151-
$aclResourcesTree = $this->_integrationData->mapResources($resources[1]['children']);
151+
$configResource = array_filter($resources, function ($node) {
152+
return isset($node['id']) && $node['id'] == 'Magento_Backend::admin';
153+
});
154+
$configResource = reset($configResource);
155+
$aclResourcesTree = $this->_integrationData->mapResources($configResource['children']);
152156

153157
return $this->encoder->encode($aclResourcesTree);
154158
}
@@ -167,7 +171,11 @@ public function getSelectedResourcesJson()
167171
$selectedResources = $this->_selectedResources;
168172
if ($this->isEverythingAllowed()) {
169173
$resources = $this->_resourceProvider->getAclResources();
170-
$selectedResources = $this->_getAllResourceIds($resources[1]['children']);
174+
$configResource = array_filter($resources, function ($node) {
175+
return isset($node['id']) && $node['id'] == 'Magento_Backend::admin';
176+
});
177+
$configResource = reset($configResource);
178+
$selectedResources = $this->_getAllResourceIds($configResource['children']);
171179
}
172180
return $this->encoder->encode($selectedResources);
173181
}

app/code/Magento/Integration/Block/Adminhtml/Integration/Edit/Tab/Webapi.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ protected function _construct()
141141

142142
/**
143143
* Retrieve saved resource
144-
*
144+
*
145145
* @return array|bool
146146
*/
147147
protected function retrieveFormResources()
@@ -176,8 +176,12 @@ public function isEverythingAllowed()
176176
public function getTree()
177177
{
178178
$resources = $this->aclResourceProvider->getAclResources();
179+
$configResource = array_filter($resources, function ($node) {
180+
return isset($node['id']) && $node['id'] == 'Magento_Backend::admin';
181+
});
182+
$configResource = reset($configResource);
179183
$rootArray = $this->integrationData->mapResources(
180-
isset($resources[1]['children']) ? $resources[1]['children'] : []
184+
isset($configResource['children']) ? $configResource['children'] : []
181185
);
182186
return $rootArray;
183187
}

app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/WebapiTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function testGetTree()
155155
{
156156
$this->webapiBlock = $this->getWebapiBlock();
157157
$resources = [
158-
1 => [ 'children' => [1, 2, 3] ]
158+
1 => [ 'id' => 'Magento_Backend::admin', 'children' => [1, 2, 3] ]
159159
];
160160
$this->aclResourceProvider->expects($this->once())
161161
->method('getAclResources')

app/code/Magento/Sales/view/frontend/layout/sales_order_print.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</referenceContainer>
1818
<referenceContainer name="content">
1919
<block class="Magento\Sales\Block\Order\PrintShipment" name="sales.order.print" template="order/view.phtml">
20-
<block class="Magento\Sales\Block\Order\PrintShipment" name="order_items" template="order/items.phtml">
20+
<block class="Magento\Sales\Block\Order\Items" name="order_items" template="order/items.phtml">
2121
<block class="Magento\Framework\View\Element\RendererList" name="sales.order.print.renderers" as="renderer.list" />
2222
<block class="Magento\Sales\Block\Order\Totals" name="order_totals" template="order/totals.phtml">
2323
<arguments>

app/code/Magento/User/Block/Role/Tab/Edit.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,12 @@ public function getSelectedResources()
199199
public function getTree()
200200
{
201201
$resources = $this->_aclResourceProvider->getAclResources();
202+
$configResource = array_filter($resources, function ($node) {
203+
return isset($node['id']) && $node['id'] == 'Magento_Backend::admin';
204+
});
205+
$configResource = reset($configResource);
202206
$rootArray = $this->_integrationData->mapResources(
203-
isset($resources[1]['children']) ? $resources[1]['children'] : []
207+
isset($configResource['children']) ? $configResource['children'] : []
204208
);
205209
return $rootArray;
206210
}

0 commit comments

Comments
 (0)