[Profile] Allow grantRole to work when role exists

This commit is contained in:
Alexei Sorokin 2020-08-11 15:00:57 +03:00
parent 535b87bb64
commit 15f7941daf

View File

@ -1162,7 +1162,10 @@ class Profile extends Managed_DataObject
$role->role = $name; $role->role = $name;
$role->created = common_sql_now(); $role->created = common_sql_now();
$result = $role->insert(); $result = $role->update();
if ($result === 0 || $result === false) {
$result = $role->insert();
}
if (!$result) { if (!$result) {
throw new Exception("Can't save role '$name' for profile '{$this->id}'"); throw new Exception("Can't save role '$name' for profile '{$this->id}'");