aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue_label.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-04-29 01:28:56 +0200
committerGitHub <noreply@github.com>2020-04-28 19:28:56 -0400
commit6b6f20b6d43b6263320ee872799373f33a751304 (patch)
tree584770b71c3482138a709e42e055f6c8c6558b90 /models/issue_label.go
parent4563eb873d3d46953aeb43a1cebf3389906b0b88 (diff)
downloadgitea-6b6f20b6d43b6263320ee872799373f33a751304.tar.gz
gitea-6b6f20b6d43b6263320ee872799373f33a751304.zip
BugFix: updateLabel can updated not allowed fields #11242 (#11242)
Diffstat (limited to 'models/issue_label.go')
-rw-r--r--models/issue_label.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/models/issue_label.go b/models/issue_label.go
index cb9c307e2b..aa2c8de009 100644
--- a/models/issue_label.go
+++ b/models/issue_label.go
@@ -246,7 +246,7 @@ func UpdateLabel(l *Label) error {
if !LabelColorPattern.MatchString(l.Color) {
return fmt.Errorf("bad color code: %s", l.Color)
}
- return updateLabel(x, l)
+ return updateLabelCols(x, l, "name", "description", "color")
}
// DeleteLabel delete a label
@@ -587,7 +587,7 @@ func GetLabelsByIssueID(issueID int64) ([]*Label, error) {
return getLabelsByIssueID(x, issueID)
}
-func updateLabel(e Engine, l *Label) error {
+func updateLabelCols(e Engine, l *Label, cols ...string) error {
_, err := e.ID(l.ID).
SetExpr("num_issues",
builder.Select("count(*)").From("issue_label").
@@ -601,7 +601,7 @@ func updateLabel(e Engine, l *Label) error {
"issue.is_closed": true,
}),
).
- AllCols().Update(l)
+ Cols(cols...).Update(l)
return err
}
@@ -653,7 +653,7 @@ func newIssueLabel(e *xorm.Session, issue *Issue, label *Label, doer *User) (err
return err
}
- return updateLabel(e, label)
+ return updateLabelCols(e, label, "num_issues", "num_closed_issue")
}
// NewIssueLabel creates a new issue-label relation.
@@ -729,7 +729,7 @@ func deleteIssueLabel(e *xorm.Session, issue *Issue, label *Label, doer *User) (
return err
}
- return updateLabel(e, label)
+ return updateLabelCols(e, label, "num_issues", "num_closed_issue")
}
// DeleteIssueLabel deletes issue-label relation.