summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2024-11-14 23:47:15 +0000
committerGo MAEDA <maeda@farend.jp>2024-11-14 23:47:15 +0000
commit5c8009c6443ef5ad9d6ed79e52429a98a7c24a62 (patch)
treee86772a6b83b7e204c140e23f3263cfd5e2b2625
parentb9fcd70289bd3e3259fb9d0a07d5b0fc763628e4 (diff)
downloadredmine-5c8009c6443ef5ad9d6ed79e52429a98a7c24a62.tar.gz
redmine-5c8009c6443ef5ad9d6ed79e52429a98a7c24a62.zip
Merged r23269 from trunk to 6.0-stable (#41749).
git-svn-id: https://svn.redmine.org/redmine/branches/6.0-stable@23273 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--Gemfile19
1 files changed, 13 insertions, 6 deletions
diff --git a/Gemfile b/Gemfile
index e5890b082..d0d6f37bf 100644
--- a/Gemfile
+++ b/Gemfile
@@ -52,16 +52,23 @@ end
# Include database gems for the adapters found in the database
# configuration file
-require 'erb'
-require 'yaml'
database_file = File.join(File.dirname(__FILE__), "config/database.yml")
if File.exist?(database_file)
- yaml_config = ERB.new(IO.read(database_file)).result
- database_config = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(yaml_config) : YAML.load(yaml_config)
- adapters = database_config.values.filter_map {|c| c['adapter']}.uniq
+ database_config = File.read(database_file)
+
+ # Requiring libraries in a Gemfile may cause Bundler warnings or
+ # unexpected behavior, especially if multiple gem versions are available.
+ # So, process database.yml through ERB only if it contains ERB syntax
+ # in the adapter setting. See https://www.redmine.org/issues/41749.
+ if database_config.match?(/^ *adapter: *<%=/)
+ require 'erb'
+ database_config = ERB.new(database_config).result
+ end
+
+ adapters = database_config.scan(/^ *adapter: *(.*)/).flatten.uniq
if adapters.any?
adapters.each do |adapter|
- case adapter
+ case adapter.strip
when 'mysql2'
gem 'mysql2', '~> 0.5.0'
gem "with_advisory_lock"