# Трудности с пониманием настройки включения приветственного баннера

**URL:** https://meta.discourse.org/t/difficulty-understanding-the-enable-welcome-banner-setting/377321
**Category:** Support
**Tags:** theme-site-settings
**Created:** [05.Август.2025 06:47:39 UTC](https://meta.discourse.org/t/difficulty-understanding-the-enable-welcome-banner-setting/377321 "2025-08-05T06:47:39Z")
**Posts on this page:** 5
**Page:** 2

<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: [08.Август.2025 06:47:44 UTC](https://meta.discourse.org/t/difficulty-understanding-the-enable-welcome-banner-setting/377321/24 "2025-08-08T06:47:44Z")

</div>

Возможно, но это, на мой взгляд, не объясняет странную задержку, которую вы наблюдаете при изменении настроек. Кроме того, мы не используем значения настроек старого сайта после начальной миграции, поэтому, думаю, это не должно влиять на работу.

---

<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: [11.Август.2025 06:45:32 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>

Так что пока я не уверен, почему это происходит, но это объяснило бы, почему кэш сохраняется, поскольку кэш строится на основе этого объекта в памяти.

Редактирование: Также обратите внимание, что я все еще не могу воспроизвести это в других местах, но на вашем сайте я могу воспроизвести это довольно надежно.

---

<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: [11.Август.2025 07:24:49 UTC](https://meta.discourse.org/t/difficulty-understanding-the-enable-welcome-banner-setting/377321/26 "2025-08-11T07:24:49Z")

</div>

Хорошо, я _думаю_, что смог воспроизвести это локально. Это ошибка в многопроцессной среде. Суть в том, что версия настроек в памяти изменяется администратором в процессе A, но затем пользователь обращается к процессу B с запросом и в итоге сам устанавливает новое значение в кэше, из-за чего в памяти кэш остаётся со старым значением.

Другие настройки сайта обходят эту проблему, обновляя все настройки через MessageBus при любом изменении:

> <https://github.com/discourse/discourse/blob/e6f9cde35e3f68d4ffb0a46a8361ce099a558ac6/lib/site_settings/db_provider.rb#L8-L8>

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

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

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

Постараюсь подготовить исправление к завтрашнему дню (сейчас у меня конец рабочего дня). Спасибо за терпение, Moin!

---

<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: [12.Август.2025 04:19:03 UTC](https://meta.discourse.org/t/difficulty-understanding-the-enable-welcome-banner-setting/377321/27 "2025-08-12T04:19:03Z")

</div>

Исправление уже объединено, это заняло немного больше времени, так как мне нужно было разобраться, как его протестировать:

> <https://github.com/discourse/discourse/pull/34242>
>
> This commit fixes an issue in multi-process setups where the following
> would ha…ppen:
> 
> 1. Admin changes a theme site setting. The new value is stored in memory
> in the process that made the change. For this example, changing
> \`enable\_welcome\_banner\` from \`true\` to \`false\`
> 2. Another user visits the site and hits another process, which has the
> old value of \`enable\_welcome\_banner\` still set to \`true\` in memory
> 3. The other user's value for \`enable\_welcome\_banner\` is cached in
> the cache for theme site settings, which is shared across all
> processes
> 
> The issue is fixed by doing the same thing as site settings: when the
> new value is saved, we send a MessageBus message to all processes via
> \`SiteSettingExtension\` which calls \`refresh!\` and reloads the in-memory
> cache of theme site settings from the DB.
> 
> c.f. https://meta.discourse.org/t/difficulty-understanding-the-enable-welcome-banner-setting/377321

Скоро разверну ваш сайт, Moin.

Редактирование: Исправление развернуто

---

<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: [14.Август.2025 04:18:35 UTC](https://meta.discourse.org/t/difficulty-understanding-the-enable-welcome-banner-setting/377321/28 "2025-08-14T04:18:35Z")

</div>

Закрываю, так как не получил информации о новых проблемах. Если возникнут вопросы, пожалуйста, дайте знать.

[Предыдущая страница](https://meta.discourse.org/t/difficulty-understanding-the-enable-welcome-banner-setting/377321.md?page=1)
