Skip to content

Commit 5354548

Browse files
author
Sergey Kovalenko
committed
Merge remote-tracking branch 'remotes/origin/develop' into MAGETWO-56012
2 parents f47d494 + 5a615bb commit 5354548

File tree

24 files changed

+241
-117
lines changed

24 files changed

+241
-117
lines changed

app/code/Magento/Backend/Model/View/Result/Redirect.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Backend\Model\UrlInterface;
1111
use Magento\Framework\App;
1212
use Magento\Framework\App\ActionFlag;
13+
use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
1314

1415
class Redirect extends \Magento\Framework\Controller\Result\Redirect
1516
{
@@ -56,7 +57,7 @@ public function setRefererOrBaseUrl()
5657
/**
5758
* {@inheritdoc}
5859
*/
59-
protected function render(App\ResponseInterface $response)
60+
protected function render(HttpResponseInterface $response)
6061
{
6162
$this->session->setIsUrlNotice($this->actionFlag->get('', AbstractAction::FLAG_IS_URLS_CHECKED));
6263
return parent::render($response);

app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ private function processRangeNumeric(FilterInterface $filter, $query, $attribute
179179
$tableSuffix = $attribute->getBackendType() === 'decimal' ? '_decimal' : '';
180180
$table = $this->resource->getTableName("catalog_product_index_eav{$tableSuffix}");
181181
$select = $this->connection->select();
182-
$linkIdField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField();
182+
$entityField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getIdentifierField();
183183

184184
$currentStoreId = $this->scopeResolver->getScope()->getId();
185185

186186
$select->from(['e' => $this->resource->getTableName('catalog_product_entity')], ['entity_id'])
187187
->join(
188188
['main_table' => $table],
189-
"main_table.{$linkIdField} = e.{$linkIdField}",
189+
"main_table.{$entityField} = e.{$entityField}",
190190
[]
191191
)
192192
->columns([$filter->getField() => 'main_table.value'])

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ public function isEverythingAllowed()
147147
*/
148148
public function getResourcesTreeJson()
149149
{
150-
$resources = $this->_resourceProvider->getAclResources();
151-
$aclResourcesTree = $this->_integrationData->mapResources($resources[1]['children']);
150+
$aclResourcesTree = $this->_integrationData->mapResources($this->getAclResources());
152151

153152
return $this->encoder->encode($aclResourcesTree);
154153
}
@@ -166,12 +165,29 @@ public function getSelectedResourcesJson()
166165
{
167166
$selectedResources = $this->_selectedResources;
168167
if ($this->isEverythingAllowed()) {
169-
$resources = $this->_resourceProvider->getAclResources();
170-
$selectedResources = $this->_getAllResourceIds($resources[1]['children']);
168+
$selectedResources = $this->_getAllResourceIds($this->getAclResources());
171169
}
172170
return $this->encoder->encode($selectedResources);
173171
}
174172

173+
/**
174+
* Get lit of all ACL resources declared in the system.
175+
*
176+
* @return array
177+
*/
178+
private function getAclResources()
179+
{
180+
$resources = $this->_resourceProvider->getAclResources();
181+
$configResource = array_filter(
182+
$resources,
183+
function ($node) {
184+
return $node['id'] == 'Magento_Backend::admin';
185+
}
186+
);
187+
$configResource = reset($configResource);
188+
return isset($configResource['children']) ? $configResource['children'] : [];
189+
}
190+
175191
/**
176192
* Whether tree has any resources.
177193
*

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Magento\Integration\Block\Adminhtml\Integration\Edit\Tab;
88

9-
use Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Info;
109
use Magento\Integration\Controller\Adminhtml\Integration as IntegrationController;
1110
use Magento\Integration\Model\Integration as IntegrationModel;
1211

@@ -174,11 +173,25 @@ public function isEverythingAllowed()
174173
* @return array
175174
*/
176175
public function getTree()
176+
{
177+
return $this->integrationData->mapResources($this->getAclResources());
178+
}
179+
180+
/**
181+
* Get lit of all ACL resources declared in the system.
182+
*
183+
* @return array
184+
*/
185+
private function getAclResources()
177186
{
178187
$resources = $this->aclResourceProvider->getAclResources();
179-
$rootArray = $this->integrationData->mapResources(
180-
isset($resources[1]['children']) ? $resources[1]['children'] : []
188+
$configResource = array_filter(
189+
$resources,
190+
function ($node) {
191+
return $node['id'] == 'Magento_Backend::admin';
192+
}
181193
);
182-
return $rootArray;
194+
$configResource = reset($configResource);
195+
return isset($configResource['children']) ? $configResource['children'] : [];
183196
}
184197
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,16 @@ public function testGetTree()
155155
{
156156
$this->webapiBlock = $this->getWebapiBlock();
157157
$resources = [
158-
1 => [ 'children' => [1, 2, 3] ]
158+
['id' => 'Magento_Backend::admin', 'children' => ['resource1', 'resource2', 'resource3']],
159+
['id' => 'Invalid_Node', 'children' => ['resource4', 'resource5', 'resource6']]
159160
];
160161
$this->aclResourceProvider->expects($this->once())
161162
->method('getAclResources')
162163
->will($this->returnValue($resources));
163164
$rootArray = "rootArrayValue";
164165
$this->integrationHelper->expects($this->once())
165166
->method('mapResources')
166-
->with([1, 2, 3])
167+
->with(['resource1', 'resource2', 'resource3'])
167168
->will($this->returnValue($rootArray));
168169
$this->assertEquals($rootArray, $this->webapiBlock->getTree());
169170
}
@@ -197,7 +198,7 @@ public function isEverythingAllowedWithSavedFromDataProvider()
197198
return [
198199
'root resource in array' => [
199200
2,
200-
['all_resources' => 0, 'resource'=>[2, 3]],
201+
['all_resources' => 0, 'resource' => [2, 3]],
201202
true
202203
],
203204
'root resource not in array' => [

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Magento\User\Block\Role\Tab;
88

9-
use Magento\Framework\App\ObjectManager;
109
use Magento\User\Controller\Adminhtml\User\Role\SaveRole;
1110

1211
/**
@@ -93,7 +92,6 @@ public function __construct(
9392
*/
9493
public function setCoreRegistry(\Magento\Framework\Registry $coreRegistry)
9594
{
96-
9795
$this->coreRegistry = $coreRegistry;
9896
}
9997

@@ -105,7 +103,6 @@ public function setCoreRegistry(\Magento\Framework\Registry $coreRegistry)
105103
*/
106104
public function getCoreRegistry()
107105
{
108-
109106
if (!($this->coreRegistry instanceof \Magento\Framework\Registry)) {
110107
return \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Framework\Registry::class);
111108
} else {
@@ -197,11 +194,25 @@ public function getSelectedResources()
197194
* @return array
198195
*/
199196
public function getTree()
197+
{
198+
return $this->_integrationData->mapResources($this->getAclResources());
199+
}
200+
201+
/**
202+
* Get lit of all ACL resources declared in the system.
203+
*
204+
* @return array
205+
*/
206+
private function getAclResources()
200207
{
201208
$resources = $this->_aclResourceProvider->getAclResources();
202-
$rootArray = $this->_integrationData->mapResources(
203-
isset($resources[1]['children']) ? $resources[1]['children'] : []
209+
$configResource = array_filter(
210+
$resources,
211+
function ($node) {
212+
return $node['id'] == 'Magento_Backend::admin';
213+
}
204214
);
205-
return $rootArray;
215+
$configResource = reset($configResource);
216+
return isset($configResource['children']) ? $configResource['children'] : [];
206217
}
207218
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,19 @@ public function getSelectedRoles($json = false)
144144
//checking if we have this data and we
145145
//don't need load it through resource model
146146
if ($user->hasData('roles')) {
147-
$uRoles = $user->getData('roles');
147+
$userRoles = $user->getData('roles');
148148
} else {
149-
$uRoles = $user->getRoles();
149+
$userRoles = $user->getRoles();
150150
}
151151

152152
if ($json) {
153153
$jsonRoles = [];
154-
foreach ($uRoles as $urid) {
155-
$jsonRoles[$urid] = 0;
154+
foreach ($userRoles as $roleId) {
155+
$jsonRoles[$roleId] = 0;
156156
}
157157
return $this->_jsonEncoder->encode((object)$jsonRoles);
158158
} else {
159-
return $uRoles;
159+
return $userRoles;
160160
}
161161
}
162162
}

app/code/Magento/User/Controller/Adminhtml/User/Save.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public function execute()
5555
return;
5656
}
5757
$model->setData($this->_getAdminUserData($data));
58-
$uRoles = $this->getRequest()->getParam('roles', []);
59-
if (count($uRoles)) {
60-
$model->setRoleId($uRoles[0]);
58+
$userRoles = $this->getRequest()->getParam('roles', []);
59+
if (count($userRoles)) {
60+
$model->setRoleId($userRoles[0]);
6161
}
6262

6363
/** @var $currentUser \Magento\User\Model\User */

app/code/Magento/User/Test/Unit/Block/Role/Tab/EditTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ protected function setUp()
8686

8787
public function testGetTree()
8888
{
89-
$resources = ['resource1', 'resource2', 'resource3'];
89+
$resources = [
90+
['id' => 'Magento_Backend::admin', 'children' => ['resource1', 'resource2', 'resource3']],
91+
['id' => 'Invalid_Node', 'children' => ['resource4', 'resource5', 'resource6']]
92+
];
9093
$mappedResources = ['mapped1', 'mapped2', 'mapped3'];
9194
$this->aclResourceProviderMock->expects($this->once())->method('getAclResources')->willReturn($resources);
9295
$this->integrationDataMock->expects($this->once())->method('mapResources')->willReturn($mappedResources);

auth.json.sample

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"http-basic": {
3+
"repo.magento.com": {
4+
"username": "<public-key>",
5+
"password": "<private-key>"
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)