mirror of https://github.com/go-gitea/gitea.git
Fixes #36630 ## Problem `StartupProblems` warnings (from `deprecatedSetting` and other `LogStartupProblem` calls) appear twice in the admin panel at `/-/admin` and `/-/admin/self_check`. `LoadCommonSettings()` is called twice during web server startup: 1. Early init via `cmd/main.go` → `InitWorkPathAndCommonConfig` → `LoadCommonSettings()` 2. Web server startup via `cmd/web.go` → `serveInstalled` → `LoadCommonSettings()` The second call re-initializes the config provider first (`InitCfgProvider`), but `StartupProblems` and `configuredPaths` are never cleared between loads, so every warning gets appended twice. ## Fix Clear `StartupProblems` and `configuredPaths` at the start of `LoadCommonSettings()` so only the final load's warnings are retained. This approach was chosen over clearing in `InitCfgProvider` because: - Warnings are produced during settings load, not provider init - Some callers set `CfgProvider` directly without calling `InitCfgProvider` - It avoids coupling correctness to a specific call ordering ## Screenshots **Result** (single warning as expected): <img width="1429" height="195" alt="Screenshot From 2026-02-16 01-27-01" src="https://github.com/user-attachments/assets/d45313a2-f981-480b-9ffc-cbced7e40bb8" /> ## testing [x] Added `TestLoadCommonSettingsClearsStartupProblems` — verifies no duplicate messages after consecutive loads [x] Added `TestLoadCommonSettingsClearsConfiguredPaths` — verifies path overlap map is identical after consecutive loads [x] All existing `modules/setting` tests pass [x] Manually verified in admin panel with deprecated `[oauth2].ENABLE` setting --------- Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> |
||
|---|---|---|
| .. | ||
| actions.go | ||
| admin.go | ||
| admin_auth.go | ||
| admin_auth_ldap.go | ||
| admin_auth_ldap_test.go | ||
| admin_auth_oauth.go | ||
| admin_auth_oauth_test.go | ||
| admin_auth_smtp.go | ||
| admin_auth_smtp_test.go | ||
| admin_regenerate.go | ||
| admin_user.go | ||
| admin_user_change_password.go | ||
| admin_user_change_password_test.go | ||
| admin_user_create.go | ||
| admin_user_create_test.go | ||
| admin_user_delete.go | ||
| admin_user_delete_test.go | ||
| admin_user_generate_access_token.go | ||
| admin_user_list.go | ||
| admin_user_must_change_password.go | ||
| admin_user_must_change_password_test.go | ||
| cert.go | ||
| cert_test.go | ||
| cmd.go | ||
| cmd_test.go | ||
| config.go | ||
| config_test.go | ||
| docs.go | ||
| doctor.go | ||
| doctor_convert.go | ||
| doctor_test.go | ||
| dump.go | ||
| dump_repo.go | ||
| embedded.go | ||
| generate.go | ||
| hook.go | ||
| hook_test.go | ||
| keys.go | ||
| mailer.go | ||
| main.go | ||
| main_test.go | ||
| manager.go | ||
| manager_logging.go | ||
| migrate.go | ||
| migrate_storage.go | ||
| migrate_storage_test.go | ||
| restore_repo.go | ||
| serv.go | ||
| web.go | ||
| web_acme.go | ||
| web_graceful.go | ||
| web_https.go | ||