# 启用欢迎横幅设置的难度

**URL:** <https://meta.discourse.org/t/difficulty-understanding-the-enable-welcome-banner-setting/377321>\
**Category:** Support\
**Tags:** theme-site-settings\
**Created:** [2025年八月5日 06:47 UTC](https://meta.discourse.org/t/difficulty-understanding-the-enable-welcome-banner-setting/377321 "2025-08-05T06:47:39Z")\
**Posts on this page:** 1\
**Showing post:** 25

<div class="post-metadata">

**Author:** ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)\
**Post date:** [2025年八月11日 06:45 UTC](https://meta.discourse.org/t/difficulty-understanding-the-enable-welcome-banner-setting/377321/25 "2025-08-11T06:45:32Z")

</div>

好的，这很有趣……它又在你的网站上的 Foundation 中丢失了，尽管它在管理界面中已启用。使用 `SiteSetting.clear_cache!(expire_theme_site_setting_cache: true)` 清除缓存_没有_清除缓存。我在这里得到两个不同的结果：

```ruby
discourse(prod)> SiteSetting.theme_site_settings_json_uncached(-1)
=> "{\"enable_welcome_banner\":true,\"search_experience\":\"search_field\"}"
discourse(prod)> SiteSetting.theme_site_settings_json(-1)
=> "{\"enable_welcome_banner\":false,\"search_experience\":\"search_field\"}"

```

然后我直接运行了这个：

```ruby
Discourse.cache.delete(SiteSettingExtension.theme_site_settings_cache_key(-1))

```

然后它奏效了？？然后我在管理中再次更改了你的设置，缓存仍然存在 🤔 我认为这里有一些奇怪的事情发生在内存中的 `theme_site_settings`：

> <https://github.com/discourse/discourse/blob/e6f9cde35e3f68d4ffb0a46a8361ce099a558ac6/lib/site_setting_extension.rb#L83-L86>

因为这给出了：

```plaintext
-2=>{:enable_welcome_banner=>false, :search_experience=>"search_field"},
 -1=>{:enable_welcome_banner=>true, :search_experience=>"search_field"}}

```

然而，如果我从数据库获取，我会得到这个，它具有正确的 `false` 值：

```ruby
ThemeSiteSetting.where(theme_id: -1)
=>
[#<ThemeSiteSetting:0x00007f9164acb2d0 id: 3, theme_id: -1, name: "enable_welcome_banner", data_type: 5, value: "f", created_at: "2025-07-16 07:04:11.117747000 +0000", updated_at: "2025-08-11 06:35:07.606301000 +0000">,
 #<ThemeSiteSetting:0x00007f9164acb190 id: 13, theme_id: -1, name: "search_experience", data_type: 7, value: "search_field", created_at: "2025-07-16 07:04:11.117747000 +0000", updated_at: "2025-07-20 20:56:49.405228000 +0000">]
discourse(prod)> Theme.find(-1).themeable_site_settings
=>
[{:setting=>:enable_welcome_banner, :default=>true, :description=>"Display a banner on your main topic list pages to welcome members and allow them to search site content", :humanized_name=>"Enable welcome banner", :type=>"bool", :value=>false},
 {:setting=>:search_experience,
  :default=>"search_icon",
  :description=>"The default position and appearance of search on desktop devices",
  :humanized_name=>"Search experience",
  :type=>"enum",
  :valid_values=>[{:name=>"search.experience.search_field", :value=>"search_field"}, {:name=>"search.experience.search_icon", :value=>"search_icon"}],
  :translate_names=>true,
  :value=>"search_field"}]

```

我们在这里进行了一些操作：

> <https://github.com/discourse/discourse/blob/e6f9cde35e3f68d4ffb0a46a8361ce099a558ac6/lib/site_setting_extension.rb#L431-L441>

以及这里：

> <https://github.com/discourse/discourse/blob/e6f9cde35e3f68d4ffb0a46a8361ce099a558ac6/lib/site_setting_extension.rb#L594-L606>

这在这里被调用：

> <https://github.com/discourse/discourse/blob/e6f9cde35e3f68d4ffb0a46a8361ce099a558ac6/app/services/themes/theme_site_setting_manager.rb#L143-L147>

所以我不确定为什么会发生这种情况，但这可以解释为什么缓存仍然存在，因为缓存是从内存中的这个对象构建的。

编辑：另外请注意，我仍然无法在其他地方重现此问题，但在你的网站上我可以相当可靠地重现它。

---

_[View the full topic](https://meta.discourse.org/t/difficulty-understanding-the-enable-welcome-banner-setting/377321)._
