diff --git a/application/forms/Security/RoleForm.php b/application/forms/Security/RoleForm.php index 58387f7aa..5dd78bc33 100644 --- a/application/forms/Security/RoleForm.php +++ b/application/forms/Security/RoleForm.php @@ -511,11 +511,7 @@ class RoleForm extends RepositoryForm } if ($this->getIdentifier() && ($newName = $this->getValue('name')) !== $this->getIdentifier()) { - $this->repository->update( - $this->getBaseTable(), - ['parent' => $newName], - Filter::where('parent', $this->getIdentifier()) - ); + $this->onRenameSuccess($this->getIdentifier(), $newName); } if (ConfigFormEventsHook::runOnSuccess($this) === false) { @@ -526,6 +522,17 @@ class RoleForm extends RepositoryForm } } + /** + * Update child roles of role $oldName, set their parent to $newName + * + * @param string $oldName + * @param string $newName + */ + protected function onRenameSuccess(string $oldName, ?string $newName): void + { + $this->repository->update($this->getBaseTable(), ['parent' => $newName], Filter::where('parent', $oldName)); + } + /** * Collect permissions and restrictions provided by Icinga Web 2 and modules *