From 15f7941dafb0817de06fc2d13b78f9e5dd706667 Mon Sep 17 00:00:00 2001 From: Alexei Sorokin Date: Tue, 11 Aug 2020 15:00:57 +0300 Subject: [PATCH] [Profile] Allow grantRole to work when role exists --- classes/Profile.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/classes/Profile.php b/classes/Profile.php index 9833c024f2..a1f9567161 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -1162,7 +1162,10 @@ class Profile extends Managed_DataObject $role->role = $name; $role->created = common_sql_now(); - $result = $role->insert(); + $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}'");