From b918a2c4fb62666d4f8bc1755f0dc5e1cdd94d53 Mon Sep 17 00:00:00 2001
From: Lunny Xiao <xiaolunwen@gmail.com>
Date: Sat, 8 Apr 2023 16:17:50 +0800
Subject: [PATCH] Fix redirect bug when creating issue from a project (#23971)

Fix #23966
---
 routers/web/repo/issue.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index 5401d60b55..d251f2043c 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -1154,8 +1154,8 @@ func NewIssuePost(ctx *context.Context) {
 	}
 
 	log.Trace("Issue created: %d/%d", repo.ID, issue.ID)
-	if ctx.FormString("redirect_after_creation") == "project" {
-		ctx.Redirect(ctx.Repo.RepoLink + "/projects/" + strconv.FormatInt(form.ProjectID, 10))
+	if ctx.FormString("redirect_after_creation") == "project" && projectID > 0 {
+		ctx.Redirect(ctx.Repo.RepoLink + "/projects/" + strconv.FormatInt(projectID, 10))
 	} else {
 		ctx.Redirect(issue.Link())
 	}