aboutsummaryrefslogtreecommitdiff
path: root/models
diff options
context:
space:
mode:
authorzeripath2023-02-21 00:15:49 +0000
committerGitHub2023-02-20 19:15:49 -0500
commit35d2fa744aae5782dcced573aa08ee9ff62c8e36 (patch)
tree1f8fe3faadea3fbc8174219889e360f1b0976553 /models
parent97aacc3ea1ea89d5781da4b86a11f8340148ca49 (diff)
Fix intermittent panic in notify issue change content (#23019)
Ensure that issue pullrequests are loaded before trying to set the self-reference. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: delvh <leon@kske.dev> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'models')
-rw-r--r--models/issues/issue.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/models/issues/issue.go b/models/issues/issue.go
index 6c76909fc..c59e9d14e 100644
--- a/models/issues/issue.go
+++ b/models/issues/issue.go
@@ -251,13 +251,15 @@ func (issue *Issue) LoadPoster(ctx context.Context) (err error) {
// LoadPullRequest loads pull request info
func (issue *Issue) LoadPullRequest(ctx context.Context) (err error) {
- if issue.IsPull && issue.PullRequest == nil {
- issue.PullRequest, err = GetPullRequestByIssueID(ctx, issue.ID)
- if err != nil {
- if IsErrPullRequestNotExist(err) {
- return err
+ if issue.IsPull {
+ if issue.PullRequest == nil {
+ issue.PullRequest, err = GetPullRequestByIssueID(ctx, issue.ID)
+ if err != nil {
+ if IsErrPullRequestNotExist(err) {
+ return err
+ }
+ return fmt.Errorf("getPullRequestByIssueID [%d]: %w", issue.ID, err)
}
- return fmt.Errorf("getPullRequestByIssueID [%d]: %w", issue.ID, err)
}
issue.PullRequest.Issue = issue
}