Fix empty project displayed in issue sidebar (#25802)

Before:

![image](1ab476dc-2f9b-4c85-9e87-105fc73af1ee)
After:

![image](786f984d-5c27-4eff-b3d9-159f68034ce4)

This issue comes from the change in #25468.
`LoadProject` will always return at least one record, so we use
`ProjectID` to check whether an issue is linked to a project in the old
code.
As other `issue.LoadXXX` functions, we need to check the return value
from `xorm.Session.Get`.

In recent unit tests, we only test `issueList.LoadAttributes()` but
don't test `issue.LoadAttributes()`. So I added a new test for
`issue.LoadAttributes()` in this PR.

---------

Co-authored-by: Denys Konovalov <privat@denyskon.de>
This commit is contained in:
yp05327 2023-07-12 23:10:35 +09:00 committed by GitHub
parent b137a03297
commit 8b89563bf1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 11 deletions

View file

@ -438,8 +438,7 @@ func UpdateIssueProject(ctx *context.Context) {
projectID := ctx.FormInt64("id")
for _, issue := range issues {
if issue.Project != nil {
oldProjectID := issue.Project.ID
if oldProjectID == projectID {
if issue.Project.ID == projectID {
continue
}
}