mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 01:05:14 +00:00
Fix PullRequestList.GetIssueIDs's logic (#31352)
fix a bug from #30490 `prs.GetIssueIDs()` will also be used in other places, e.g. `InvalidateCodeComments` so we should not add `if pr.Issue == nil` in it, or if `pr.Issue` is already loaded, you will not get the issueID in the results list and this is not an expected result. So this will caused a bug: before calling `InvalidateCodeComments`, all `pr.Issues` in `prs` are loaded, so `issueIDs` in this function will always be `[]`. ![image](https://github.com/go-gitea/gitea/assets/18380374/ef94d9d2-0bf9-455a-abd6-4d5e6497db7c) (cherry picked from commit e61e9a36b7117bab2cb122a95d606a86527ed45d)
This commit is contained in:
parent
12e23ee199
commit
b5ea092964
|
@ -198,8 +198,10 @@ func (prs PullRequestList) LoadIssues(ctx context.Context) (IssueList, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
// Load issues.
|
||||
issueIDs := prs.GetIssueIDs()
|
||||
// Load issues which are not loaded
|
||||
issueIDs := container.FilterSlice(prs, func(pr *PullRequest) (int64, bool) {
|
||||
return pr.IssueID, pr.Issue == nil && pr.IssueID > 0
|
||||
})
|
||||
issues := make(map[int64]*Issue, len(issueIDs))
|
||||
if err := db.GetEngine(ctx).
|
||||
In("id", issueIDs).
|
||||
|
@ -235,10 +237,7 @@ func (prs PullRequestList) LoadIssues(ctx context.Context) (IssueList, error) {
|
|||
// GetIssueIDs returns all issue ids
|
||||
func (prs PullRequestList) GetIssueIDs() []int64 {
|
||||
return container.FilterSlice(prs, func(pr *PullRequest) (int64, bool) {
|
||||
if pr.Issue == nil {
|
||||
return pr.IssueID, pr.IssueID > 0
|
||||
}
|
||||
return 0, false
|
||||
return pr.IssueID, pr.IssueID > 0
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue