From 5510ed34f10a80c01a13455a6d493c6fb35c2b17 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Tue, 4 Jul 2023 06:59:01 -0400 Subject: [PATCH] Fix the nil pointer when assigning issues to projects (#25665) (#25677) Backport #25665 by @Zettat123 Fixes #25649 Caused by #25468 Co-authored-by: Zettat123 --- 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 e525f2c43f3a..c568b1c07164 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 6da9edfd0b80..b1033fe0030e 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 {