Skip to content

Commit 324da66

Browse files
authored
Remove "Administrators" name from the query to fetch an administrators role
1 parent 4a41ec4 commit 324da66

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

setup/src/Magento/Setup/Model/AdminAccount.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,30 +236,29 @@ private function saveAdminUserRole($adminId)
236236
}
237237

238238
/**
239-
* Gets the "Administrators" role id, the special role created by data fixture in Authorization module.
239+
* Gets an administrators role id, the special role created by data fixture in Authorization module.
240240
*
241-
* @return int The id of the Administrators role
242-
* @throws \Exception If Administrators role not found or problem connecting with database.
241+
* @return int The id of an administrators role
242+
* @throws \Exception If an administrators role not found or problem connecting with database.
243243
*/
244244
private function retrieveAdministratorsRoleId()
245245
{
246-
// Get Administrators role id to use as parent_id
246+
// Get an administrators role id to use as parent_id
247247
$administratorsRoleData = [
248248
'parent_id' => 0,
249249
'tree_level' => 1,
250250
'role_type' => Group::ROLE_TYPE,
251251
'user_id' => 0,
252252
'user_type' => UserContextInterface::USER_TYPE_ADMIN,
253-
'role_name' => 'Administrators',
254253
];
255254
$result = $this->connection->fetchRow(
256255
'SELECT * FROM ' . $this->getTableName('authorization_role') . ' ' .
257256
'WHERE parent_id = :parent_id AND tree_level = :tree_level AND role_type = :role_type AND ' .
258-
'user_id = :user_id AND user_type = :user_type AND role_name = :role_name',
257+
'user_id = :user_id AND user_type = :user_type ORDER BY sort_order DESC',
259258
$administratorsRoleData
260259
);
261260
if (empty($result)) {
262-
throw new \Exception('No Administrators role was found, data fixture needs to be run');
261+
throw new \Exception('No administrators role was found, data fixture needs to be run');
263262
} else {
264263
// Found at least one, use first
265264
return $result['role_id'];

0 commit comments

Comments
 (0)