FIX: "Replace Text" didn't list "Welcome Topic" when "General" category is missing (#27182)

Replacing the text of seeded topics doesn't require categories to exist, so this change removes that requirement for updates.
This commit is contained in:
Gerhard Schlager
2024-05-27 09:57:30 +02:00
committed by GitHub
parent d1191b7f5f
commit 9aede9c8d8
2 changed files with 58 additions and 4 deletions

View File

@ -22,7 +22,10 @@ module SeedData
def update(site_setting_names: nil, skip_changed: false)
I18n.with_locale(@locale) do
topics(site_setting_names: site_setting_names).each do |params|
topics(
site_setting_names: site_setting_names,
require_existing_categories: false,
).each do |params|
update_topic(**params.except(:category, :after_create), skip_changed: skip_changed)
end
end
@ -38,7 +41,7 @@ module SeedData
def reseed_options
I18n.with_locale(@locale) do
topics
topics(require_existing_categories: false)
.map do |params|
post = find_post(params[:site_setting_name])
next unless post
@ -51,7 +54,13 @@ module SeedData
private
def topics(site_setting_names: nil, include_welcome_topics: true, include_legal_topics: true)
def topics(
site_setting_names: nil,
include_welcome_topics: true,
include_legal_topics: true,
require_existing_categories: true
)
general_category = Category.find_by(id: SiteSetting.general_category_id)
staff_category = Category.find_by(id: SiteSetting.staff_category_id)
feedback_category = Category.find_by(id: SiteSetting.meta_category_id)
feedback_category_hashtag =
@ -105,7 +114,7 @@ module SeedData
if include_welcome_topics
# Welcome Topic
if general_category = Category.find_by(id: SiteSetting.general_category_id)
if general_category || !require_existing_categories
site_info_quote =
if SiteSetting.title.present? && SiteSetting.site_description.present?
<<~RAW