aboutsummaryrefslogtreecommitdiffstats
path: root/templates/repo/issue
diff options
context:
space:
mode:
authorsillyguodong <33891828+sillyguodong@users.noreply.github.com>2023-04-20 07:50:00 +0800
committerGitHub <noreply@github.com>2023-04-19 19:50:00 -0400
commitbfecf3bd89e00f8ecae782087182e1952076c9af (patch)
tree74e4e1084f4eb2ad7d798ea61ed0cba9119178fe /templates/repo/issue
parentda6e9f63df7411ecbe630178fd4bb694e537c453 (diff)
downloadgitea-bfecf3bd89e00f8ecae782087182e1952076c9af.tar.gz
gitea-bfecf3bd89e00f8ecae782087182e1952076c9af.zip
Fix internal sever error when visiting a PR that bound to the deleted team (#24127)
Close: #23738 The actual cause of `500 Internal Server Error` in the issue is not what is descirbed in the issue. The actual cause is that after deleting team, if there is a PR which has requested reivew from the deleted team, the comment could not match with the deleted team by `assgin_team_id`. So the value of `.AssigneeTeam` (see below code block) is `nil` which cause `500 error`. https://github.com/go-gitea/gitea/blob/1c8bc4081a4f4d0d921ac218cb724ce97924d410/templates/repo/issue/view_content/comments.tmpl#L691-L695 To fix this bug, there are the following problems to be resolved: - [x] 1. ~~Stroe the name of the team in `content` column when inserting `comment` into DB in case that we cannot get the name of team after it is deleted. But for comments that already exist, just display "Unknown Team"~~ Just display "Ghost Team" in the comment if the assgined team is deleted. - [x] 2. Delete the PR&team binding (the row of which `review_team_id = ${team_id} ` in table `review`) when deleting team. - [x] 3.For already exist and undeleted binding rows in in table `review`, ~~we can delete these rows when executing migrations.~~ they do not affect the function, so won't delete them.
Diffstat (limited to 'templates/repo/issue')
-rw-r--r--templates/repo/issue/view_content/comments.tmpl9
1 files changed, 7 insertions, 2 deletions
diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl
index 251f205a03..39a6722e84 100644
--- a/templates/repo/issue/view_content/comments.tmpl
+++ b/templates/repo/issue/view_content/comments.tmpl
@@ -688,10 +688,15 @@
{{$.locale.Tr "repo.issues.review.add_review_request" (.Assignee.GetDisplayName|Escape) $createdStr | Safe}}
{{end}}
{{else}}
+ <!-- If the assigned team is deleted, just displaying "Ghost Team" in the comment -->
+ {{$teamName := "Ghost Team"}}
+ {{if .AssigneeTeam}}
+ {{$teamName = .AssigneeTeam.Name}}
+ {{end}}
{{if .RemovedAssignee}}
- {{$.locale.Tr "repo.issues.review.remove_review_request" (.AssigneeTeam.Name|Escape) $createdStr | Safe}}
+ {{$.locale.Tr "repo.issues.review.remove_review_request" ($teamName|Escape) $createdStr | Safe}}
{{else}}
- {{$.locale.Tr "repo.issues.review.add_review_request" (.AssigneeTeam.Name|Escape) $createdStr | Safe}}
+ {{$.locale.Tr "repo.issues.review.add_review_request" ($teamName|Escape) $createdStr | Safe}}
{{end}}
{{end}}
</span>