From c3b7120042af5fb2345b6efd315954deb698b4c0 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Thu, 21 Sep 2023 11:42:34 +0800 Subject: [PATCH 001/484] Add index to `issue_user.issue_id` (#27154) (#27158) Backport #27154 by @JakobDev This fixes a performance bottleneck. It was discovered by Codeberg. Every where query on that table (which has grown big over time) uses this column, but there is no index on it. See this part of the log which was posted on Matrix: ``` 2023/09/10 00:52:01 ...rs/web/repo/issue.go:1446:ViewIssue() [W] [Slow SQL Query] UPDATE `issue_user` SET is_read=? WHERE uid=? AND issue_id=? [true x y] - 51.395434887s 2023/09/10 00:52:01 ...rs/web/repo/issue.go:1447:ViewIssue() [E] ReadBy: Error 1205 (HY000): Lock wait timeout exceeded; try restarting transaction 2023/09/10 00:52:01 ...eb/routing/logger.go:102:func1() [I] router: completed GET /Codeberg/Community/issues/1201 for [::ffff:xxx]:0, 500 Internal Server Error in 52384.2ms @ repo/issue.go:1256(repo.ViewIssue) ``` Co-authored-by: JakobDev --- models/issues/issue_user.go | 2 +- models/migrations/migrations.go | 2 ++ models/migrations/v1_21/v277.go | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 models/migrations/v1_21/v277.go diff --git a/models/issues/issue_user.go b/models/issues/issue_user.go index d053b1d543..24bb74648d 100644 --- a/models/issues/issue_user.go +++ b/models/issues/issue_user.go @@ -15,7 +15,7 @@ import ( type IssueUser struct { ID int64 `xorm:"pk autoincr"` UID int64 `xorm:"INDEX"` // User ID. - IssueID int64 + IssueID int64 `xorm:"INDEX"` IsRead bool IsMentioned bool } diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 3524077ea4..38fff37bed 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -534,6 +534,8 @@ var migrations = []Migration{ NewMigration("Add ScheduleID for ActionRun", v1_21.AddScheduleIDForActionRun), // v276 -> v277 NewMigration("Add RemoteAddress to mirrors", v1_21.AddRemoteAddressToMirrors), + // v277 -> v278 + NewMigration("Add Index to issue_user.issue_id", v1_21.AddIndexToIssueUserIssueID), } // GetCurrentDBVersion returns the current db version diff --git a/models/migrations/v1_21/v277.go b/models/migrations/v1_21/v277.go new file mode 100644 index 0000000000..12529160b7 --- /dev/null +++ b/models/migrations/v1_21/v277.go @@ -0,0 +1,16 @@ +// Copyright 2023 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package v1_21 //nolint + +import ( + "xorm.io/xorm" +) + +func AddIndexToIssueUserIssueID(x *xorm.Engine) error { + type IssueUser struct { + IssueID int64 `xorm:"INDEX"` + } + + return x.Sync(new(IssueUser)) +} From 0ca233258da1837d3588d5f47734453bd862de73 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Thu, 21 Sep 2023 18:15:20 +0800 Subject: [PATCH 002/484] Fix organization field being null in POST /orgs/{orgid}/teams (#27150) (#27163) Backport #27150 by @memphis88 Similarly to the fix in https://github.com/go-gitea/gitea/pull/24694, this addresses the team creation not returning the organization information in the response. This fix is connected to the [issue](https://gitea.com/gitea/terraform-provider-gitea/issues/27) discovered in the terraform provider. Moreover, the [documentation](https://docs.gitea.com/api/1.20/#tag/organization/operation/orgCreateTeam) suggests that the response body should include the `organization` field (currently being `null`). Co-authored-by: Dionysios Kakouris <1369451+memphis88@users.noreply.github.com> --- routers/api/v1/org/team.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go index 519572ee51..83cbfe68d0 100644 --- a/routers/api/v1/org/team.go +++ b/routers/api/v1/org/team.go @@ -248,7 +248,7 @@ func CreateTeam(ctx *context.APIContext) { return } - apiTeam, err := convert.ToTeam(ctx, team) + apiTeam, err := convert.ToTeam(ctx, team, true) if err != nil { ctx.InternalServerError(err) return From b34727c632580fe9ce292f34aa65618956a5bad0 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Thu, 21 Sep 2023 20:09:44 +0800 Subject: [PATCH 003/484] Fix the variable regexp pattern on web page (#27161) (#27164) Backport #27161 by @lng2020 same as (https://github.com/go-gitea/gitea/pull/26910) Co-authored-by: Nanguan Lin <70063547+lng2020@users.noreply.github.com> --- templates/shared/variables/variable_list.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/shared/variables/variable_list.tmpl b/templates/shared/variables/variable_list.tmpl index a9456321e4..3a389ffaf8 100644 --- a/templates/shared/variables/variable_list.tmpl +++ b/templates/shared/variables/variable_list.tmpl @@ -73,7 +73,7 @@ name="name" id="dialog-variable-name" value="{{.name}}" - pattern="^[a-zA-Z_][a-zA-Z0-9_]*$" + pattern="^(?!GITEA_|GITHUB_)[a-zA-Z_][a-zA-Z0-9_]*$" placeholder="{{.locale.Tr "secrets.creation.name_placeholder"}}" > From 8d9e2d07f3f84a86265fdbe0ab7fcf63cc34ddbd Mon Sep 17 00:00:00 2001 From: Giteabot Date: Thu, 21 Sep 2023 21:22:38 +0800 Subject: [PATCH 004/484] Fix repo sub menu (#27169) (#27170) Backport #27169 by @wxiaoguang Fix #27166 Co-authored-by: wxiaoguang --- web_src/css/base.css | 1 - web_src/css/repo.css | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web_src/css/base.css b/web_src/css/base.css index a305701332..6b33ec4111 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -420,7 +420,6 @@ a.silenced:hover { } a.label, -.repository-menu a, .ui.search .results a, .ui .menu a, .ui.cards a.card, diff --git a/web_src/css/repo.css b/web_src/css/repo.css index 8ec9908f73..b7b14f7407 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -2044,7 +2044,7 @@ border: none; display: flex; align-items: center; - padding: 0 0.5em; /* make the UI look better for narrow (mobile) view */ + padding: 0; overflow: hidden; } @@ -2056,7 +2056,8 @@ align-items: center; justify-content: center; gap: 0.25em; - padding: 0 0.25em; + padding: 0 0.5em; /* make the UI look better for narrow (mobile) view */ + text-decoration: none; } .repository .repository-summary .sub-menu .item.active { From 2e49a4da4891b1eda86e2748ecbc03bf04c9f209 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Fri, 22 Sep 2023 00:24:07 +0800 Subject: [PATCH 005/484] Fix dropdown icon position (#27175) (#27177) Backport #27175 by @wxiaoguang According to https://fomantic-ui.com/modules/dropdown.html and our "devtest" page, many dropdown elements has incorrect "icon" position. This PR fixes all of them. Fix #27173 Co-authored-by: wxiaoguang --- templates/admin/base/search.tmpl | 2 +- templates/admin/emails/list.tmpl | 2 +- templates/admin/repo/search.tmpl | 2 +- templates/admin/user/list.tmpl | 6 ++++-- templates/explore/repo_search.tmpl | 2 +- templates/explore/search.tmpl | 2 +- templates/projects/list.tmpl | 2 +- templates/repo/activity.tmpl | 6 ++---- templates/repo/commits.tmpl | 4 +--- templates/repo/issue/filters.tmpl | 14 +++++++------- templates/repo/issue/labels/label_list.tmpl | 8 ++++---- templates/repo/issue/list.tmpl | 8 ++++---- templates/repo/issue/milestones.tmpl | 2 +- templates/user/dashboard/milestones.tmpl | 2 +- templates/user/dashboard/navbar.tmpl | 2 +- .../notification/notification_subscriptions.tmpl | 4 ++-- 16 files changed, 33 insertions(+), 35 deletions(-) diff --git a/templates/admin/base/search.tmpl b/templates/admin/base/search.tmpl index 19977f05a9..865cc8830f 100644 --- a/templates/admin/base/search.tmpl +++ b/templates/admin/base/search.tmpl @@ -9,8 +9,8 @@