From 7c3196ceaca30411e5fbfd45eb7ac28b261a85c2 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Fri, 24 Feb 2023 23:46:11 +0200 Subject: Avoid warning for system setting when start up (#23054) (#23116) Backport #23054 Partially fix #23050 After #22294 merged, it always has a warning log like `cannot get context cache` when starting up. This should not affect any real life but it's annoying. This PR will fix the problem. That means when starting up, getting the system settings will not try from the cache but will read from the database directly. Co-authored-by: Lunny Xiao Co-authored-by: Lauris BH --- modules/repository/commits_test.go | 2 +- modules/templates/helper.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/repository/commits_test.go b/modules/repository/commits_test.go index 2bd8de38aa..a407083f3a 100644 --- a/modules/repository/commits_test.go +++ b/modules/repository/commits_test.go @@ -106,7 +106,7 @@ func enableGravatar(t *testing.T) { err := system_model.SetSettingNoVersion(db.DefaultContext, system_model.KeyPictureDisableGravatar, "false") assert.NoError(t, err) setting.GravatarSource = "https://secure.gravatar.com/avatar" - err = system_model.Init() + err = system_model.Init(db.DefaultContext) assert.NoError(t, err) } diff --git a/modules/templates/helper.go b/modules/templates/helper.go index b7bd07670c..17ac68dc6b 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -92,7 +92,7 @@ func NewFuncMap() []template.FuncMap { return setting.AssetVersion }, "DisableGravatar": func(ctx context.Context) bool { - return system_model.GetSettingBool(ctx, system_model.KeyPictureDisableGravatar) + return system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar) }, "DefaultShowFullName": func() bool { return setting.UI.DefaultShowFullName -- cgit v1.2.3