diff --git a/models/issue_comment.go b/models/issue_comment.go index 2eadba810b..e133cc049b 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 970b3fcc4c..015e7f128d 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 40993e54d2..381c80cdaf 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -145,14 +145,16 @@ {{else if eq .Type 7}} -