From ff140d40507d7cf607de712d84849db244db6054 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Tue, 4 Jul 2023 18:26:24 +0800 Subject: [PATCH] Fix the nil pointer when assigning issues to projects (#25665) Fixes #25649 Caused by #25468 --- routers/web/org/projects.go | 8 +++++--- routers/web/repo/projects.go | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/routers/web/org/projects.go b/routers/web/org/projects.go index e525f2c43..c568b1c07 100644 --- a/routers/web/org/projects.go +++ b/routers/web/org/projects.go @@ -436,9 +436,11 @@ func UpdateIssueProject(ctx *context.Context) { projectID := ctx.FormInt64("id") for _, issue := range issues { - oldProjectID := issue.Project.ID - if oldProjectID == projectID { - continue + if issue.Project != nil { + oldProjectID := issue.Project.ID + if oldProjectID == projectID { + continue + } } if err := issues_model.ChangeProjectAssign(issue, ctx.Doer, projectID); err != nil { diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go index 6da9edfd0..b1033fe00 100644 --- a/routers/web/repo/projects.go +++ b/routers/web/repo/projects.go @@ -385,9 +385,11 @@ func UpdateIssueProject(ctx *context.Context) { projectID := ctx.FormInt64("id") for _, issue := range issues { - oldProjectID := issue.Project.ID - if oldProjectID == projectID { - continue + if issue.Project != nil { + oldProjectID := issue.Project.ID + if oldProjectID == projectID { + continue + } } if err := issues_model.ChangeProjectAssign(issue, ctx.Doer, projectID); err != nil {