summaryrefslogtreecommitdiff
path: root/app/services/users
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-08 00:10:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-08 00:10:26 +0000
commit9695fcf51937fbba91c8bf9ea076ba376fe2a4b1 (patch)
tree55b2c576e10348a2317da6cdf4e38af1dc16fb64 /app/services/users
parent364e69bafd235e5689fba44bb5eef37305cb6c6d (diff)
downloadgitlab-ce-9695fcf51937fbba91c8bf9ea076ba376fe2a4b1.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/users')
-rw-r--r--app/services/users/destroy_service.rb37
1 files changed, 7 insertions, 30 deletions
diff --git a/app/services/users/destroy_service.rb b/app/services/users/destroy_service.rb
index a378cb09854..60e3d3418e9 100644
--- a/app/services/users/destroy_service.rb
+++ b/app/services/users/destroy_service.rb
@@ -10,7 +10,9 @@ module Users
@current_user = current_user
end
- # Synchronously destroys +user+
+ # Asynchronously destroys +user+
+ # Migrating the associated user records, and post-migration cleanup is
+ # handled by the Users::MigrateRecordsToGhostUserWorker cron worker.
#
# The operation will fail if the user is the sole owner of any groups. To
# force the groups to be destroyed, pass `delete_solo_owned_groups: true` in
@@ -24,10 +26,7 @@ module Users
# a hard deletion without destroying solo-owned groups, pass
# `delete_solo_owned_groups: false, hard_delete: true` in +options+.
#
- # To make the service asynchronous, a new behaviour is being introduced
- # behind the user_destroy_with_limited_execution_time_worker feature flag.
- # Migrating the associated user records, and post-migration cleanup is
- # handled by the Users::MigrateRecordsToGhostUserWorker cron worker.
+
def execute(user, options = {})
delete_solo_owned_groups = options.fetch(:delete_solo_owned_groups, options[:hard_delete])
@@ -62,31 +61,9 @@ module Users
yield(user) if block_given?
hard_delete = options.fetch(:hard_delete, false)
-
- if Feature.enabled?(:user_destroy_with_limited_execution_time_worker)
- Users::GhostUserMigration.create!(user: user,
- initiator_user: current_user,
- hard_delete: hard_delete)
-
- else
- MigrateToGhostUserService.new(user).execute(hard_delete: options[:hard_delete])
-
- response = Snippets::BulkDestroyService.new(current_user, user.snippets)
- .execute(skip_authorization: hard_delete)
- raise DestroyError, response.message if response.error?
-
- # Rails attempts to load all related records into memory before
- # destroying: https://github.com/rails/rails/issues/22510
- # This ensures we delete records in batches.
- user.destroy_dependent_associations_in_batches(exclude: [:snippets])
- user.nullify_dependent_associations_in_batches
-
- # Destroy the namespace after destroying the user since certain methods may depend on the namespace existing
- user_data = user.destroy
- namespace.destroy
-
- user_data
- end
+ Users::GhostUserMigration.create!(user: user,
+ initiator_user: current_user,
+ hard_delete: hard_delete)
end
end
end