[Profile] Allow grantRole to work when role exists

This commit is contained in:
Alexei Sorokin 2020-08-11 15:00:57 +03:00 committed by Diogo Peralta Cordeiro
parent cce2c763d3
commit e051572f84

View File

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