diff options
author | Go MAEDA <maeda@farend.jp> | 2024-02-05 13:39:02 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2024-02-05 13:39:02 +0000 |
commit | 61e223f69818baad181d17bc830496a6015bca79 (patch) | |
tree | 6a56868d368833a74650be6fdbfff5c27edcf305 | |
parent | 609ddf2577fcaa172e4802d61d0aa13e59e9f16c (diff) | |
download | redmine-61e223f69818baad181d17bc830496a6015bca79.tar.gz redmine-61e223f69818baad181d17bc830496a6015bca79.zip |
Fix RuntimeError on `reload!` in the Rails console (#38155).
Patch by Thomas Löber (@tloeber).
git-svn-id: https://svn.redmine.org/redmine/trunk@22681 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | lib/redmine/access_control.rb | 1 | ||||
-rw-r--r-- | lib/redmine/asset_path.rb | 2 | ||||
-rw-r--r-- | lib/redmine/menu_manager.rb | 4 | ||||
-rw-r--r-- | lib/redmine/plugin.rb | 2 | ||||
-rw-r--r-- | lib/redmine/scm/base.rb | 1 | ||||
-rw-r--r-- | lib/redmine/wiki_formatting.rb | 7 |
6 files changed, 11 insertions, 6 deletions
diff --git a/lib/redmine/access_control.rb b/lib/redmine/access_control.rb index 515386e19..3c1208df6 100644 --- a/lib/redmine/access_control.rb +++ b/lib/redmine/access_control.rb @@ -84,6 +84,7 @@ module Redmine def permission(name, hash, options={}) @permissions ||= [] + @permissions.reject! {|p| p.name == name} options[:project_module] = @project_module @permissions << Permission.new(name, hash, options) end diff --git a/lib/redmine/asset_path.rb b/lib/redmine/asset_path.rb index b115fe187..4284e1971 100644 --- a/lib/redmine/asset_path.rb +++ b/lib/redmine/asset_path.rb @@ -202,7 +202,7 @@ module Redmine end end - ASSET_URL_PATTERN = /(url\(\s*["']?([^"'\s)]+)\s*["']?\s*\))/ + ASSET_URL_PATTERN = /(url\(\s*["']?([^"'\s)]+)\s*["']?\s*\))/ unless defined? ASSET_URL_PATTERN def convert_path(input, conversion) input.gsub(ASSET_URL_PATTERN) do |matched| diff --git a/lib/redmine/menu_manager.rb b/lib/redmine/menu_manager.rb index 39922b96c..66ae6f488 100644 --- a/lib/redmine/menu_manager.rb +++ b/lib/redmine/menu_manager.rb @@ -292,6 +292,8 @@ module Redmine target_root = @menu_items.root end + target_root.children.reject! {|item| item.name == name} + # menu item position if first = options.delete(:first) target_root.prepend(MenuItem.new(name, url, options)) @@ -379,8 +381,6 @@ module Redmine # Adds a child at given position def add_at(child, position) - raise "Child already added" if find {|node| node.name == child.name} - @children = @children.insert(position, child) child.parent = self child diff --git a/lib/redmine/plugin.rb b/lib/redmine/plugin.rb index c9b2c07ba..f0dbcc30d 100644 --- a/lib/redmine/plugin.rb +++ b/lib/redmine/plugin.rb @@ -125,7 +125,7 @@ module Redmine # Warn for potential settings[:partial] collisions if p.configurable? partial = p.settings[:partial] - if @used_partials[partial] + if @used_partials[partial] && @used_partials[partial] != p.id Rails.logger.warn( "WARNING: settings partial '#{partial}' is declared in '#{p.id}' plugin " \ "but it is already used by plugin '#{@used_partials[partial]}'. " \ diff --git a/lib/redmine/scm/base.rb b/lib/redmine/scm/base.rb index b313754b7..4f965df4e 100644 --- a/lib/redmine/scm/base.rb +++ b/lib/redmine/scm/base.rb @@ -28,6 +28,7 @@ module Redmine # Add a new SCM adapter and repository def add(scm_name) @scms ||= [] + @scms.delete(scm_name) @scms << scm_name end diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index 28b1ea130..95455417a 100644 --- a/lib/redmine/wiki_formatting.rb +++ b/lib/redmine/wiki_formatting.rb @@ -34,7 +34,6 @@ module Redmine def register(name, *args) options = args.last.is_a?(Hash) ? args.pop : {} name = name.to_s - raise ArgumentError, "format name '#{name}' is already taken" if @@formatters[name] formatter, helper, parser = if args.any? @@ -44,12 +43,16 @@ module Redmine end raise "A formatter class is required" if formatter.nil? - @@formatters[name] = { + entry = { :formatter => formatter, :helper => helper, :html_parser => parser, :label => options[:label] || name.humanize } + if @@formatters[name] && @@formatters[name] != entry + raise ArgumentError, "format name '#{name}' is already taken" + end + @@formatters[name] = entry end def formatter |