Skip to content

A platform for community discussion. Free, open, simple.

DEV: Fix YAML load in new Ruby (#19500)

Rafael dos Santos Silvab8c1289c7a8a
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