diff --git a/models/issue_comment.go b/models/issue_comment.go index 2eadba810..e133cc049 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -214,12 +214,13 @@ func (c *Comment) LoadLabel() error { has, err := x.ID(c.LabelID).Get(&label) if err != nil { return err - } else if !has { - return ErrLabelNotExist{ - LabelID: c.LabelID, - } + } else if has { + c.Label = &label + } else { + // Ignore Label is deleted, but not clear this table + log.Warn("Commit %d cannot load label %d", c.ID, c.LabelID) } - c.Label = &label + return nil } diff --git a/models/issue_label.go b/models/issue_label.go index 970b3fcc4..015e7f128 100644 --- a/models/issue_label.go +++ b/models/issue_label.go @@ -249,6 +249,11 @@ func DeleteLabel(repoID, labelID int64) error { return err } + // Clear label id in comment table + if _, err = sess.Where("label_id = ?", labelID).Cols("label_id").Update(&Comment{}); err != nil { + return err + } + return sess.Commit() } diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 40993e54d..381c80cda 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -145,14 +145,16 @@ {{else if eq .Type 7}} -