From 567a68a0bf78c8d70f08c8ab948fdbb455225aa9 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Mon, 19 Feb 2024 19:25:58 +0800 Subject: [PATCH] Remove DataRaceCheck (#29258) Since #26254, it started using `{{ctx.Locale.Tr ...}}` Now the `ctx` seems stable enough, so the check could be removed. --- modules/context/context_template.go | 14 -------------- templates/base/footer.tmpl | 1 - templates/base/head.tmpl | 1 - 3 files changed, 16 deletions(-) diff --git a/modules/context/context_template.go b/modules/context/context_template.go index ba90fc170a33..7878d409caf4 100644 --- a/modules/context/context_template.go +++ b/modules/context/context_template.go @@ -5,10 +5,7 @@ package context import ( "context" - "errors" "time" - - "code.gitea.io/gitea/modules/log" ) var _ context.Context = TemplateContext(nil) @@ -36,14 +33,3 @@ func (c TemplateContext) Err() error { func (c TemplateContext) Value(key any) any { return c.parentContext().Value(key) } - -// DataRaceCheck checks whether the template context function "ctx()" returns the consistent context -// as the current template's rendering context (request context), to help to find data race issues as early as possible. -// When the code is proven to be correct and stable, this function should be removed. -func (c TemplateContext) DataRaceCheck(dataCtx context.Context) (string, error) { - if c.parentContext() != dataCtx { - log.Error("TemplateContext.DataRaceCheck: parent context mismatch\n%s", log.Stack(2)) - return "", errors.New("parent context mismatch") - } - return "", nil -} diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl index d65a3626a48e..fed426a46927 100644 --- a/templates/base/footer.tmpl +++ b/templates/base/footer.tmpl @@ -16,6 +16,5 @@ {{template "custom/footer" .}} - {{ctx.DataRaceCheck $.Context}} diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index e910bb0cd992..d7e28474e7f7 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -30,7 +30,6 @@ {{template "custom/header" .}} - {{ctx.DataRaceCheck $.Context}} {{template "custom/body_outer_pre" .}}