@ -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
}