Skip to content

Commit a98f47a

Browse files
committed
MC-30109: Deleting an empty user model caused deleting admin role
1 parent bd1696b commit a98f47a

File tree

1 file changed

+5
-5
lines changed
  • app/code/Magento/User/Model/ResourceModel

1 file changed

+5
-5
lines changed

app/code/Magento/User/Model/ResourceModel/User.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,17 @@ public function delete(\Magento\Framework\Model\AbstractModel $user)
258258

259259
$uid = $user->getId();
260260
$connection->beginTransaction();
261-
try {
262-
if ($uid) {
261+
if ($uid) {
262+
try {
263263
$connection->delete($this->getMainTable(), ['user_id = ?' => $uid]);
264264
$connection->delete(
265265
$this->getTable('authorization_role'),
266266
['user_id = ?' => $uid, 'user_type = ?' => UserContextInterface::USER_TYPE_ADMIN]
267267
);
268+
} catch (\Magento\Framework\Exception\LocalizedException $e) {
269+
$connection->rollBack();
270+
return false;
268271
}
269-
} catch (\Magento\Framework\Exception\LocalizedException $e) {
270-
$connection->rollBack();
271-
return false;
272272
}
273273
$connection->commit();
274274
$this->_afterDelete($user);

0 commit comments

Comments
 (0)