Skip to content

Ensure delete user deletes all comments (#21067)#21068

Merged
lunny merged 3 commits into
go-gitea:release/v1.17from
lunny:lunny/fix_delete_user2
Sep 5, 2022
Merged

Ensure delete user deletes all comments (#21067)#21068
lunny merged 3 commits into
go-gitea:release/v1.17from
lunny:lunny/fix_delete_user2

Conversation

@lunny

@lunny lunny commented Sep 5, 2022

Copy link
Copy Markdown
Member

Backport #21067

There is a mistake in the batched delete comments part of DeleteUser which causes some comments to not be deleted

The code incorrectly updates the start of the limit clause resulting in most comments not being deleted.

			if err = e.Where("type=? AND poster_id=?", issues_model.CommentTypeComment, u.ID).Limit(batchSize, start).Find(&comments); err != nil {

should be:

			if err = e.Where("type=? AND poster_id=?", issues_model.CommentTypeComment, u.ID).Limit(batchSize, 0).Find(&comments); err != nil {

@lunny lunny added the type/bug label Sep 5, 2022
@lunny lunny added this to the 1.17.2 milestone Sep 5, 2022
@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Sep 5, 2022
@zeripath zeripath changed the title Fix delete user missed some comments Fix delete user missed some comments (#21067) Sep 5, 2022
Comment thread models/user.go Outdated

@zeripath zeripath left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved as this fixes a fairly serious bug - BUT the delete comment code is really quite inefficient. There is no need get all of this stuff out of the DB.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Sep 5, 2022
@lunny lunny merged commit 084797b into go-gitea:release/v1.17 Sep 5, 2022
@lunny lunny deleted the lunny/fix_delete_user2 branch September 5, 2022 22:49
@zeripath zeripath changed the title Fix delete user missed some comments (#21067) Ensure delete user deletes all comments (#21067) Sep 6, 2022
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants