Commit 1a7c008f authored by Dylan Griffith's avatar Dylan Griffith

Trigger Elasticsearch indexing when public group moved to private

This fixes https://gitlab.com/gitlab-org/gitlab/issues/37766 which is
caused by the fact that we leave the stale permissions data in the index
after a group is moved to another group.
parent 0330bd0a
...@@ -39,9 +39,15 @@ module Groups ...@@ -39,9 +39,15 @@ module Groups
ensure_ownership ensure_ownership
end end
post_update_hooks(@updated_project_ids)
true true
end end
# Overridden in EE
def post_update_hooks(updated_project_ids)
end
def ensure_allowed_transfer def ensure_allowed_transfer
raise_transfer_error(:group_is_already_root) if group_is_already_root? raise_transfer_error(:group_is_already_root) if group_is_already_root?
raise_transfer_error(:same_parent_as_current) if same_parent? raise_transfer_error(:same_parent_as_current) if same_parent?
...@@ -96,9 +102,16 @@ module Groups ...@@ -96,9 +102,16 @@ module Groups
.where(id: descendants.select(:id)) .where(id: descendants.select(:id))
.update_all(visibility_level: @new_parent_group.visibility_level) .update_all(visibility_level: @new_parent_group.visibility_level)
@group projects_to_update = @group
.all_projects .all_projects
.where("visibility_level > ?", @new_parent_group.visibility_level) .where("visibility_level > ?", @new_parent_group.visibility_level)
# Used in post_update_hooks in EE. Must use pluck (and not select)
# here as after we perform the update below we won't be able to find
# these records again.
@updated_project_ids = projects_to_update.pluck(:id)
projects_to_update
.update_all(visibility_level: @new_parent_group.visibility_level) .update_all(visibility_level: @new_parent_group.visibility_level)
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment