From 3cc7f763c3c22ae4c3b5331f8b72b7009c5b11ea Mon Sep 17 00:00:00 2001 From: Max Wipfli Date: Sun, 2 Jun 2024 04:32:20 +0200 Subject: [PATCH] Only update poster in issue/comment list if it has been loaded (#31216) Previously, all posters were updated, even if they were not part of posterMaps. In that case, a ghost user was erroneously inserted. Fixes #31213. --- models/issues/comment_list.go | 4 +++- models/issues/issue_list.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/models/issues/comment_list.go b/models/issues/comment_list.go index 6b4ad80eed5..61ac1c8f562 100644 --- a/models/issues/comment_list.go +++ b/models/issues/comment_list.go @@ -32,7 +32,9 @@ func (comments CommentList) LoadPosters(ctx context.Context) error { } for _, comment := range comments { - comment.Poster = getPoster(comment.PosterID, posterMaps) + if comment.Poster == nil { + comment.Poster = getPoster(comment.PosterID, posterMaps) + } } return nil } diff --git a/models/issues/issue_list.go b/models/issues/issue_list.go index 0dd37a04df2..2c007c72ec6 100644 --- a/models/issues/issue_list.go +++ b/models/issues/issue_list.go @@ -87,7 +87,9 @@ func (issues IssueList) LoadPosters(ctx context.Context) error { } for _, issue := range issues { - issue.Poster = getPoster(issue.PosterID, posterMaps) + if issue.Poster == nil { + issue.Poster = getPoster(issue.PosterID, posterMaps) + } } return nil }