mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-04 13:44:17 +08:00
Currently, when updating several settings in bulk, they are updated in a non-deterministic order. This means that if Setting B depends on Setting A being enabled, and we try to enable B and A together, there's a chance that fails. This is why we need to remove the up-front values_are_valid policy from the service as well. This change first sorts the settings topologically, i.e. in order of dependency, so if C depends on B depends on A, then we will update them in order [A, B, C].
34 lines
1.1 KiB
Ruby
34 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
class Admin::Config::FontsController < Admin::AdminController
|
|
def index
|
|
end
|
|
|
|
def update
|
|
SiteSetting::Update.call(
|
|
guardian:,
|
|
params: {
|
|
settings: [
|
|
{ setting_name: "base_font", value: params[:base_font] },
|
|
{ setting_name: "heading_font", value: params[:heading_font] },
|
|
{
|
|
setting_name: "default_text_size",
|
|
value: params[:default_text_size],
|
|
backfill: params[:update_existing_users] == "true",
|
|
},
|
|
],
|
|
},
|
|
) do
|
|
on_success { render json: success_json }
|
|
on_exceptions { |e| raise Discourse::InvalidParameters, e }
|
|
on_failed_policy(:settings_are_visible) do |policy|
|
|
raise Discourse::InvalidParameters, policy.reason
|
|
end
|
|
on_failed_policy(:settings_are_unshadowed_globally) do |policy|
|
|
raise Discourse::InvalidParameters, policy.reason
|
|
end
|
|
on_failed_policy(:settings_are_configurable) do |policy|
|
|
raise Discourse::InvalidParameters, policy.reason
|
|
end
|
|
end
|
|
end
|
|
end
|