Skip to content

Commit 878c2ce

Browse files
authored
Prevent NPE due to missing repo in regression in #17551 (#17697)
1 parent 1f1ae57 commit 878c2ce

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

models/issue.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -1928,26 +1928,38 @@ func (issue *Issue) getParticipantIDsByIssue(e db.Engine) ([]int64, error) {
19281928

19291929
// Get Blocked By Dependencies, aka all issues this issue is blocked by.
19301930
func (issue *Issue) getBlockedByDependencies(e db.Engine) (issueDeps []*DependencyInfo, err error) {
1931-
return issueDeps, e.
1931+
err = e.
19321932
Table("issue").
19331933
Join("INNER", "repository", "repository.id = issue.repo_id").
19341934
Join("INNER", "issue_dependency", "issue_dependency.dependency_id = issue.id").
19351935
Where("issue_id = ?", issue.ID).
19361936
// sort by repo id then created date, with the issues of the same repo at the beginning of the list
19371937
OrderBy("CASE WHEN issue.repo_id = " + strconv.FormatInt(issue.RepoID, 10) + " THEN 0 ELSE issue.repo_id END, issue.created_unix DESC").
19381938
Find(&issueDeps)
1939+
1940+
for _, depInfo := range issueDeps {
1941+
depInfo.Issue.Repo = &depInfo.Repository
1942+
}
1943+
1944+
return issueDeps, err
19391945
}
19401946

19411947
// Get Blocking Dependencies, aka all issues this issue blocks.
19421948
func (issue *Issue) getBlockingDependencies(e db.Engine) (issueDeps []*DependencyInfo, err error) {
1943-
return issueDeps, e.
1949+
err = e.
19441950
Table("issue").
19451951
Join("INNER", "repository", "repository.id = issue.repo_id").
19461952
Join("INNER", "issue_dependency", "issue_dependency.issue_id = issue.id").
19471953
Where("dependency_id = ?", issue.ID).
19481954
// sort by repo id then created date, with the issues of the same repo at the beginning of the list
19491955
OrderBy("CASE WHEN issue.repo_id = " + strconv.FormatInt(issue.RepoID, 10) + " THEN 0 ELSE issue.repo_id END, issue.created_unix DESC").
19501956
Find(&issueDeps)
1957+
1958+
for _, depInfo := range issueDeps {
1959+
depInfo.Issue.Repo = &depInfo.Repository
1960+
}
1961+
1962+
return issueDeps, err
19511963
}
19521964

19531965
// BlockedByDependencies finds all Dependencies an issue is blocked by

0 commit comments

Comments
 (0)