Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 9c4e95d

Browse files
authored
🔃 [EngCom] Public Pull Requests - 2.3-develop
Accepted Public Pull Requests: - magento/magento2#18142: Replace intval() function by using direct type casting to (int) where no default value is needed (by @mage2pratik) - magento/magento2#18136: [2.3] Update labels section in README.md (by @sidolov) - magento/magento2#18117: Change sort order for customer group options (by @dmytro-ch) - magento/magento2#18102: Replace sort callbacks to spaceship operator (by @mage2pratik) - magento-commerce/async-import#15: add support HTTP DELETE method for async bulk request by adding mergi� (by @anvasiliev) Fixed GitHub Issues: - magento/magento2#18101: Wrong sort order for customer groups in customer grid filter (reported by @sreichel) has been fixed in magento/magento2#18117 by @dmytro-ch in 2.3-develop branch Related commits: 1. 568fa46 2. ed99490
2 parents 8fd89cf + b6e2a77 commit 9c4e95d

File tree

33 files changed

+215
-177
lines changed

33 files changed

+215
-177
lines changed

README.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,8 @@ Magento is thankful for any contribution that can improve our code base, documen
4141
</a>
4242

4343
<h3>Labels applied by the Magento team</h3>
44-
45-
| Label | Description |
46-
| ------------- |-------------|
47-
| ![DOC](http://devdocs.magento.com/common/images/github_DOC.png) | Affects Documentation domain. |
48-
| ![PROD](http://devdocs.magento.com/common/images/github_PROD.png) | Affects the Product team (mostly feature requests or business logic change). |
49-
| ![TECH](http://devdocs.magento.com/common/images/github_TECH.png) | Affects Architect Group (mostly to make decisions around technology changes). |
50-
| ![accept](http://devdocs.magento.com/common/images/github_accept.png) | The pull request has been accepted and will be merged into mainline code. |
51-
| ![reject](http://devdocs.magento.com/common/images/github_reject.png) | The pull request has been rejected and will not be merged into mainline code. Possible reasons can include but are not limited to: issue has already been fixed in another code contribution, or there is an issue with the code contribution. |
52-
| ![bug report](http://devdocs.magento.com/common/images/github_bug.png) | The Magento Team has confirmed that this issue contains the minimum required information to reproduce. |
53-
| ![acknowledged](http://devdocs.magento.com/common/images/gitHub_acknowledged.png) | The Magento Team has validated the issue and an internal ticket has been created. |
54-
| ![in progress](http://devdocs.magento.com/common/images/github_inProgress.png) | The internal ticket is currently in progress, fix is scheduled to be delivered. |
55-
| ![needs update](http://devdocs.magento.com/common/images/github_needsUpdate.png) | The Magento Team needs additional information from the reporter to properly prioritize and process the issue or pull request. |
56-
57-
To learn more about issue gate labels click [here](https://github.com/magento/magento2/wiki/Magento-Issue-Gates)
44+
We apply labels to public Pull Requests and Issues to help other participants retrieve additional information about current progress, component assignments, Magento release lines, and much more.
45+
Please review the <a href="https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#labels">Code Contributions guide</a> for detailed information on labels used in Magento 2 repositories.
5846

5947
<h2>Reporting security issues</h2>
6048

app/code/Magento/Backend/Block/Widget/Button/ButtonList.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
namespace Magento\Backend\Block\Widget\Button;
88

99
/**
10+
* Button list widget
11+
*
1012
* @api
1113
* @since 100.0.2
1214
*/
@@ -127,12 +129,6 @@ public function getItems()
127129
*/
128130
public function sortButtons(Item $itemA, Item $itemB)
129131
{
130-
$sortOrderA = (int) $itemA->getSortOrder();
131-
$sortOrderB = (int) $itemB->getSortOrder();
132-
133-
if ($sortOrderA == $sortOrderB) {
134-
return 0;
135-
}
136-
return ($sortOrderA < $sortOrderB) ? -1 : 1;
132+
return (int)$itemA->getSortOrder() <=> (int)$itemB->getSortOrder();
137133
}
138134
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,10 +1014,8 @@ public function shakeSelections($firstItem, $secondItem)
10141014
$secondItem->getPosition(),
10151015
$secondItem->getSelectionId(),
10161016
];
1017-
if ($aPosition == $bPosition) {
1018-
return 0;
1019-
}
1020-
return $aPosition < $bPosition ? -1 : 1;
1017+
1018+
return $aPosition <=> $bPosition;
10211019
}
10221020

10231021
/**

app/code/Magento/Config/Model/Config/Structure/Mapper/Sorting.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
namespace Magento\Config\Model\Config\Structure\Mapper;
1111

1212
/**
13+
* Sorting mapper
14+
*
1315
* @api
1416
* @since 100.0.2
1517
*/
@@ -30,6 +32,8 @@ public function map(array $data)
3032
}
3133

3234
/**
35+
* Process config
36+
*
3337
* @param array $data
3438
* @return array
3539
*/
@@ -62,10 +66,6 @@ protected function _cmp($elementA, $elementB)
6266
$sortIndexB = (float)$elementB['sortOrder'];
6367
}
6468

65-
if ($sortIndexA == $sortIndexB) {
66-
return 0;
67-
}
68-
69-
return $sortIndexA < $sortIndexB ? -1 : 1;
69+
return $sortIndexA <=> $sortIndexB;
7070
}
7171
}

app/code/Magento/Customer/Model/GroupManagement.php

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88
namespace Magento\Customer\Model;
99

1010
use Magento\Customer\Api\Data\GroupInterface;
11+
use Magento\Customer\Api\Data\GroupInterfaceFactory;
12+
use Magento\Customer\Api\GroupRepositoryInterface;
13+
use Magento\Framework\Api\FilterBuilder;
1114
use Magento\Framework\Api\SearchCriteriaBuilder;
15+
use Magento\Framework\Api\SortOrderBuilder;
1216
use Magento\Framework\App\Config\ScopeConfigInterface;
13-
use Magento\Framework\Api\FilterBuilder;
17+
use Magento\Framework\App\ObjectManager;
18+
use Magento\Framework\Data\Collection;
1419
use Magento\Framework\Exception\NoSuchEntityException;
1520
use Magento\Store\Model\StoreManagerInterface;
16-
use Magento\Customer\Api\GroupRepositoryInterface;
17-
use Magento\Customer\Api\Data\GroupInterfaceFactory;
18-
use Magento\Customer\Model\GroupFactory;
1921

2022
/**
23+
* The class contains methods for getting information about a customer group
24+
*
2125
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2226
*/
2327
class GroupManagement implements \Magento\Customer\Api\GroupManagementInterface
@@ -65,6 +69,11 @@ class GroupManagement implements \Magento\Customer\Api\GroupManagementInterface
6569
*/
6670
protected $filterBuilder;
6771

72+
/**
73+
* @var SortOrderBuilder
74+
*/
75+
private $sortOrderBuilder;
76+
6877
/**
6978
* @param StoreManagerInterface $storeManager
7079
* @param ScopeConfigInterface $scopeConfig
@@ -73,6 +82,7 @@ class GroupManagement implements \Magento\Customer\Api\GroupManagementInterface
7382
* @param GroupInterfaceFactory $groupDataFactory
7483
* @param SearchCriteriaBuilder $searchCriteriaBuilder
7584
* @param FilterBuilder $filterBuilder
85+
* @param SortOrderBuilder $sortOrderBuilder
7686
*/
7787
public function __construct(
7888
StoreManagerInterface $storeManager,
@@ -81,7 +91,8 @@ public function __construct(
8191
GroupRepositoryInterface $groupRepository,
8292
GroupInterfaceFactory $groupDataFactory,
8393
SearchCriteriaBuilder $searchCriteriaBuilder,
84-
FilterBuilder $filterBuilder
94+
FilterBuilder $filterBuilder,
95+
SortOrderBuilder $sortOrderBuilder = null
8596
) {
8697
$this->storeManager = $storeManager;
8798
$this->scopeConfig = $scopeConfig;
@@ -90,10 +101,12 @@ public function __construct(
90101
$this->groupDataFactory = $groupDataFactory;
91102
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
92103
$this->filterBuilder = $filterBuilder;
104+
$this->sortOrderBuilder = $sortOrderBuilder ?: ObjectManager::getInstance()
105+
->get(SortOrderBuilder::class);
93106
}
94107

95108
/**
96-
* {@inheritdoc}
109+
* @inheritdoc
97110
*/
98111
public function isReadonly($groupId)
99112
{
@@ -107,7 +120,7 @@ public function isReadonly($groupId)
107120
}
108121

109122
/**
110-
* {@inheritdoc}
123+
* @inheritdoc
111124
*/
112125
public function getDefaultGroup($storeId = null)
113126
{
@@ -133,15 +146,15 @@ public function getDefaultGroup($storeId = null)
133146
}
134147

135148
/**
136-
* {@inheritdoc}
149+
* @inheritdoc
137150
*/
138151
public function getNotLoggedInGroup()
139152
{
140153
return $this->groupRepository->getById(self::NOT_LOGGED_IN_ID);
141154
}
142155

143156
/**
144-
* {@inheritdoc}
157+
* @inheritdoc
145158
*/
146159
public function getLoggedInGroups()
147160
{
@@ -155,15 +168,20 @@ public function getLoggedInGroups()
155168
->setConditionType('neq')
156169
->setValue(self::CUST_GROUP_ALL)
157170
->create();
171+
$groupNameSortOrder = $this->sortOrderBuilder
172+
->setField('customer_group_code')
173+
->setDirection(Collection::SORT_ORDER_ASC)
174+
->create();
158175
$searchCriteria = $this->searchCriteriaBuilder
159176
->addFilters($notLoggedInFilter)
160177
->addFilters($groupAll)
178+
->addSortOrder($groupNameSortOrder)
161179
->create();
162180
return $this->groupRepository->getList($searchCriteria)->getItems();
163181
}
164182

165183
/**
166-
* {@inheritdoc}
184+
* @inheritdoc
167185
*/
168186
public function getAllCustomersGroup()
169187
{

app/code/Magento/Deploy/Model/DeploymentConfig/ImporterPool.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ public function __construct(
110110
}
111111

112112
/**
113+
* Retrieves sections names
114+
*
113115
* Retrieves names of sections for configuration files whose data is read from these files for import
114116
* to appropriate application sources.
115117
*
@@ -187,14 +189,7 @@ public function getValidator($section)
187189
private function sort(array $data)
188190
{
189191
uasort($data, function (array $a, array $b) {
190-
$a['sort_order'] = $this->getSortOrder($a);
191-
$b['sort_order'] = $this->getSortOrder($b);
192-
193-
if ($a['sort_order'] == $b['sort_order']) {
194-
return 0;
195-
}
196-
197-
return ($a['sort_order'] < $b['sort_order']) ? -1 : 1;
192+
return $this->getSortOrder($a) <=> $this->getSortOrder($b);
198193
});
199194

200195
return $data;

app/code/Magento/Paypal/Model/Express/Checkout.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,10 +1056,7 @@ protected function _prepareShippingOptions(Address $address, $mayReturnEmpty = f
10561056
*/
10571057
protected static function cmpShippingOptions(DataObject $option1, DataObject $option2)
10581058
{
1059-
if ($option1->getAmount() == $option2->getAmount()) {
1060-
return 0;
1061-
}
1062-
return ($option1->getAmount() < $option2->getAmount()) ? -1 : 1;
1059+
return $option1->getAmount() <=> $option2->getAmount();
10631060
}
10641061

10651062
/**

app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function getOrder()
6161

6262
/**
6363
* Compose and get order full history.
64+
*
6465
* Consists of the status history comments as well as of invoices, shipments and creditmemos creations
6566
*
6667
* @TODO This method requires refactoring. Need to create separate model for comment history handling
@@ -218,15 +219,15 @@ protected function _prepareHistoryItem($label, $notified, $created, $comment = '
218219
}
219220

220221
/**
221-
* {@inheritdoc}
222+
* @inheritdoc
222223
*/
223224
public function getTabLabel()
224225
{
225226
return __('Comments History');
226227
}
227228

228229
/**
229-
* {@inheritdoc}
230+
* @inheritdoc
230231
*/
231232
public function getTabTitle()
232233
{
@@ -264,15 +265,15 @@ public function getTabUrl()
264265
}
265266

266267
/**
267-
* {@inheritdoc}
268+
* @inheritdoc
268269
*/
269270
public function canShowTab()
270271
{
271272
return true;
272273
}
273274

274275
/**
275-
* {@inheritdoc}
276+
* @inheritdoc
276277
*/
277278
public function isHidden()
278279
{
@@ -303,11 +304,7 @@ public static function sortHistoryByTimestamp($a, $b)
303304
$createdAtA = $a['created_at'];
304305
$createdAtB = $b['created_at'];
305306

306-
/** @var $createdAtA \DateTime */
307-
if ($createdAtA->getTimestamp() == $createdAtB->getTimestamp()) {
308-
return 0;
309-
}
310-
return $createdAtA->getTimestamp() < $createdAtB->getTimestamp() ? -1 : 1;
307+
return $createdAtA->getTimestamp() <=> $createdAtB->getTimestamp();
311308
}
312309

313310
/**

app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ public function __construct(
158158
}
159159

160160
/**
161-
* Returns the total width in points of the string using the specified font and
162-
* size.
161+
* Returns the total width in points of the string using the specified font and size.
163162
*
164163
* This is not the most efficient way to perform this calculation. I'm
165164
* concentrating optimization efforts on the upcoming layout manager class.
@@ -230,7 +229,7 @@ public function getAlignCenter($string, $x, $columnWidth, \Zend_Pdf_Resource_Fon
230229
* Insert logo to pdf page
231230
*
232231
* @param \Zend_Pdf_Page &$page
233-
* @param null $store
232+
* @param string|null $store
234233
* @return void
235234
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
236235
*/
@@ -285,7 +284,7 @@ protected function insertLogo(&$page, $store = null)
285284
* Insert address to pdf page
286285
*
287286
* @param \Zend_Pdf_Page &$page
288-
* @param null $store
287+
* @param string|null $store
289288
* @return void
290289
*/
291290
protected function insertAddress(&$page, $store = null)
@@ -641,11 +640,7 @@ protected function _sortTotalsList($a, $b)
641640
return 0;
642641
}
643642

644-
if ($a['sort_order'] == $b['sort_order']) {
645-
return 0;
646-
}
647-
648-
return $a['sort_order'] > $b['sort_order'] ? 1 : -1;
643+
return $a['sort_order'] <=> $b['sort_order'];
649644
}
650645

651646
/**

app/code/Magento/Ui/DataProvider/Modifier/Pool.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,7 @@ public function getModifiersInstances()
8888
protected function sort(array $data)
8989
{
9090
usort($data, function (array $a, array $b) {
91-
$a['sortOrder'] = $this->getSortOrder($a);
92-
$b['sortOrder'] = $this->getSortOrder($b);
93-
94-
if ($a['sortOrder'] == $b['sortOrder']) {
95-
return 0;
96-
}
97-
98-
return ($a['sortOrder'] < $b['sortOrder']) ? -1 : 1;
91+
return $this->getSortOrder($a) <=> $this->getSortOrder($b);
9992
});
10093

10194
return $data;

app/code/Magento/WebapiAsync/Controller/Rest/Asynchronous/InputParamsResolver.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ public function resolve()
9595
$this->requestValidator->validate();
9696
$webapiResolvedParams = [];
9797
$inputData = $this->request->getRequestData();
98+
99+
$httpMethod = $this->request->getHttpMethod();
100+
if ($httpMethod == \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_DELETE) {
101+
$requestBodyParams = $this->request->getBodyParams();
102+
$inputData = array_merge($requestBodyParams, $inputData);
103+
}
104+
98105
foreach ($inputData as $key => $singleEntityParams) {
99106
$webapiResolvedParams[$key] = $this->resolveBulkItemParams($singleEntityParams);
100107
}
@@ -103,6 +110,8 @@ public function resolve()
103110
}
104111

105112
/**
113+
* Returns route.
114+
*
106115
* @return \Magento\Webapi\Controller\Rest\Router\Route
107116
*/
108117
public function getRoute()
@@ -111,8 +120,7 @@ public function getRoute()
111120
}
112121

113122
/**
114-
* Convert the input array from key-value format to a list of parameters
115-
* suitable for the specified class / method.
123+
* Convert the input array from key-value format to a list of parameters suitable for the specified class / method.
116124
*
117125
* Instead of \Magento\Webapi\Controller\Rest\InputParamsResolver
118126
* we don't need to merge body params with url params and use only body params

0 commit comments

Comments
 (0)