mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 09:44:00 +01:00
Check ctx.Written()
for GetActionIssue
(#25698)
Fix #25697. Just avoid panic, maybe there's another bug to trigger this case. --------- Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
parent
c0edb9b78b
commit
3c05aa4927
5 changed files with 20 additions and 11 deletions
|
@ -1977,7 +1977,7 @@ func GetActionIssue(ctx *context.Context) *issues_model.Issue {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err = issue.LoadAttributes(ctx); err != nil {
|
if err = issue.LoadAttributes(ctx); err != nil {
|
||||||
ctx.ServerError("LoadAttributes", nil)
|
ctx.ServerError("LoadAttributes", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return issue
|
return issue
|
||||||
|
@ -3282,6 +3282,9 @@ func filterXRefComments(ctx *context.Context, issue *issues_model.Issue) error {
|
||||||
// GetIssueAttachments returns attachments for the issue
|
// GetIssueAttachments returns attachments for the issue
|
||||||
func GetIssueAttachments(ctx *context.Context) {
|
func GetIssueAttachments(ctx *context.Context) {
|
||||||
issue := GetActionIssue(ctx)
|
issue := GetActionIssue(ctx)
|
||||||
|
if ctx.Written() {
|
||||||
|
return
|
||||||
|
}
|
||||||
attachments := make([]*api.Attachment, len(issue.Attachments))
|
attachments := make([]*api.Attachment, len(issue.Attachments))
|
||||||
for i := 0; i < len(issue.Attachments); i++ {
|
for i := 0; i < len(issue.Attachments); i++ {
|
||||||
attachments[i] = convert.ToAttachment(issue.Attachments[i])
|
attachments[i] = convert.ToAttachment(issue.Attachments[i])
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
// GetContentHistoryOverview get overview
|
// GetContentHistoryOverview get overview
|
||||||
func GetContentHistoryOverview(ctx *context.Context) {
|
func GetContentHistoryOverview(ctx *context.Context) {
|
||||||
issue := GetActionIssue(ctx)
|
issue := GetActionIssue(ctx)
|
||||||
if issue == nil {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,11 +43,11 @@ func GetContentHistoryOverview(ctx *context.Context) {
|
||||||
// GetContentHistoryList get list
|
// GetContentHistoryList get list
|
||||||
func GetContentHistoryList(ctx *context.Context) {
|
func GetContentHistoryList(ctx *context.Context) {
|
||||||
issue := GetActionIssue(ctx)
|
issue := GetActionIssue(ctx)
|
||||||
commentID := ctx.FormInt64("comment_id")
|
if ctx.Written() {
|
||||||
if issue == nil {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
commentID := ctx.FormInt64("comment_id")
|
||||||
items, _ := issues_model.FetchIssueContentHistoryList(ctx, issue.ID, commentID)
|
items, _ := issues_model.FetchIssueContentHistoryList(ctx, issue.ID, commentID)
|
||||||
|
|
||||||
// render history list to HTML for frontend dropdown items: (name, value)
|
// render history list to HTML for frontend dropdown items: (name, value)
|
||||||
|
@ -113,7 +113,7 @@ func canSoftDeleteContentHistory(ctx *context.Context, issue *issues_model.Issue
|
||||||
// GetContentHistoryDetail get detail
|
// GetContentHistoryDetail get detail
|
||||||
func GetContentHistoryDetail(ctx *context.Context) {
|
func GetContentHistoryDetail(ctx *context.Context) {
|
||||||
issue := GetActionIssue(ctx)
|
issue := GetActionIssue(ctx)
|
||||||
if issue == nil {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ func GetContentHistoryDetail(ctx *context.Context) {
|
||||||
// SoftDeleteContentHistory soft delete
|
// SoftDeleteContentHistory soft delete
|
||||||
func SoftDeleteContentHistory(ctx *context.Context) {
|
func SoftDeleteContentHistory(ctx *context.Context) {
|
||||||
issue := GetActionIssue(ctx)
|
issue := GetActionIssue(ctx)
|
||||||
if issue == nil {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@ import (
|
||||||
// IssuePinOrUnpin pin or unpin a Issue
|
// IssuePinOrUnpin pin or unpin a Issue
|
||||||
func IssuePinOrUnpin(ctx *context.Context) {
|
func IssuePinOrUnpin(ctx *context.Context) {
|
||||||
issue := GetActionIssue(ctx)
|
issue := GetActionIssue(ctx)
|
||||||
|
if ctx.Written() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// If we don't do this, it will crash when trying to add the pin event to the comment history
|
// If we don't do this, it will crash when trying to add the pin event to the comment history
|
||||||
err := issue.LoadRepo(ctx)
|
err := issue.LoadRepo(ctx)
|
||||||
|
|
|
@ -1491,10 +1491,10 @@ func DownloadPullDiffOrPatch(ctx *context.Context, patch bool) {
|
||||||
// UpdatePullRequestTarget change pull request's target branch
|
// UpdatePullRequestTarget change pull request's target branch
|
||||||
func UpdatePullRequestTarget(ctx *context.Context) {
|
func UpdatePullRequestTarget(ctx *context.Context) {
|
||||||
issue := GetActionIssue(ctx)
|
issue := GetActionIssue(ctx)
|
||||||
pr := issue.PullRequest
|
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
pr := issue.PullRequest
|
||||||
if !issue.IsPull {
|
if !issue.IsPull {
|
||||||
ctx.Error(http.StatusNotFound)
|
ctx.Error(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
|
|
|
@ -28,6 +28,9 @@ const (
|
||||||
// RenderNewCodeCommentForm will render the form for creating a new review comment
|
// RenderNewCodeCommentForm will render the form for creating a new review comment
|
||||||
func RenderNewCodeCommentForm(ctx *context.Context) {
|
func RenderNewCodeCommentForm(ctx *context.Context) {
|
||||||
issue := GetActionIssue(ctx)
|
issue := GetActionIssue(ctx)
|
||||||
|
if ctx.Written() {
|
||||||
|
return
|
||||||
|
}
|
||||||
if !issue.IsPull {
|
if !issue.IsPull {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -52,10 +55,10 @@ func RenderNewCodeCommentForm(ctx *context.Context) {
|
||||||
func CreateCodeComment(ctx *context.Context) {
|
func CreateCodeComment(ctx *context.Context) {
|
||||||
form := web.GetForm(ctx).(*forms.CodeCommentForm)
|
form := web.GetForm(ctx).(*forms.CodeCommentForm)
|
||||||
issue := GetActionIssue(ctx)
|
issue := GetActionIssue(ctx)
|
||||||
if !issue.IsPull {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ctx.Written() {
|
if !issue.IsPull {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,10 +188,10 @@ func renderConversation(ctx *context.Context, comment *issues_model.Comment) {
|
||||||
func SubmitReview(ctx *context.Context) {
|
func SubmitReview(ctx *context.Context) {
|
||||||
form := web.GetForm(ctx).(*forms.SubmitReviewForm)
|
form := web.GetForm(ctx).(*forms.SubmitReviewForm)
|
||||||
issue := GetActionIssue(ctx)
|
issue := GetActionIssue(ctx)
|
||||||
if !issue.IsPull {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ctx.Written() {
|
if !issue.IsPull {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
|
|
Loading…
Reference in a new issue