From b8c1289c7a8a7743e8001f6a6dd7becfb6954f3c Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Fri, 16 Dec 2022 17:07:18 -0300 Subject: [PATCH] DEV: Fix YAML load in new Ruby (#19500) --- lib/site_settings/yaml_loader.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/site_settings/yaml_loader.rb b/lib/site_settings/yaml_loader.rb index 91603d05cf0..2ec4c4a412e 100644 --- a/lib/site_settings/yaml_loader.rb +++ b/lib/site_settings/yaml_loader.rb @@ -8,7 +8,7 @@ class SiteSettings::YamlLoader end def load - yaml = YAML.load_file(@file) + yaml = load_yaml(@file) yaml.each_key do |category| yaml[category].each do |setting_name, hash| if hash.is_a?(Hash) @@ -31,4 +31,14 @@ class SiteSettings::YamlLoader end end end + + private + + def load_yaml(path) + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') + YAML.load_file(path, aliases: true) + else + YAML.load_file(path) + end + end end