summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Griffith <dyl.griffith@gmail.com>2019-12-06 12:31:28 +1100
committerSean McGivern <sean@gitlab.com>2019-12-06 13:58:32 +0000
commit2509f7978d3097adc0c4e47a49475c16274285dd (patch)
treecab3f37e2f6ea6ebc99376385c23edeca070da87
parent97a41ac6af97842bb00222c5291f72e05c801481 (diff)
downloadgitlab-ce-2509f7978d3097adc0c4e47a49475c16274285dd.tar.gz
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.
-rw-r--r--app/services/groups/transfer_service.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/services/groups/transfer_service.rb b/app/services/groups/transfer_service.rb
index 6902b7bd529..a2e6774f1d2 100644
--- a/app/services/groups/transfer_service.rb
+++ b/app/services/groups/transfer_service.rb
@@ -39,9 +39,15 @@ module Groups
ensure_ownership
end
+ post_update_hooks(@updated_project_ids)
+
true
end
+ # Overridden in EE
+ def post_update_hooks(updated_project_ids)
+ end
+
def ensure_allowed_transfer
raise_transfer_error(:group_is_already_root) if group_is_already_root?
raise_transfer_error(:same_parent_as_current) if same_parent?
@@ -96,9 +102,16 @@ module Groups
.where(id: descendants.select(:id))
.update_all(visibility_level: @new_parent_group.visibility_level)
- @group
+ projects_to_update = @group
.all_projects
.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)
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -115,3 +128,5 @@ module Groups
end
end
end
+
+Groups::TransferService.prepend_if_ee('EE::Groups::TransferService')