Package: redmine
Version: 2.5.1-2~bpo70+5
Severity: minor
Tags: patch

Hey!

I am running redmine from backports and packaged the necessary dependencies
of the redmine_dmsf[1] plugin. After installing (rake) the plugin, I get
the following error message:
  |   Rendered admin/plugins.html.erb within layouts/admin (64.9ms)
  | Completed 500 Internal Server Error in 149.0ms
  | 
  | ActionView::Template::Error (can not load translations from
  | /usr/lib/ruby/vendor_ruby/../locales/en.yml: #<TypeError: no implicit
  | conversion from nil to integer>):
  |     1: <%= title l(:label_plugins) %>
  |     2:
  |     3: <% if @plugins.any? %>
  |     4: <table class="list plugins">
  |   lib/redmine/i18n.rb:153:in `init_translations'
  |   lib/redmine/i18n.rb:167:in `lookup'
  |   lib/redmine/i18n.rb:27:in `l'
  |   app/views/admin/plugins.html.erb:1:in
  | `_app_views_admin_plugins_html_erb__1842134549454110237_58120100'

The interesting part here is that somehow
"/usr/lib/ruby/vendor_ruby/../locales/en.yml" gets added to the list of
translations to load; this path, of course, does not exist and the loading
fails.
This is the list of files to load without plugins:
    "/usr/lib/ruby/vendor_ruby/active_support/locale/en.yml", 
    "/usr/lib/ruby/vendor_ruby/active_model/locale/en.yml",
    "/usr/lib/ruby/vendor_ruby/active_record/locale/en.yml",
    "/usr/lib/ruby/vendor_ruby/action_view/locale/en.yml",
    "/usr/share/redmine/config/locales/en.yml"
when adding/enabling redmine_dmsf these paths get added:
    "/usr/lib/ruby/vendor_ruby/active_support/locale/en.yml",
    "/usr/lib/ruby/vendor_ruby/active_model/locale/en.yml",
    "/usr/lib/ruby/vendor_ruby/active_record/locale/en.yml",
    "/usr/lib/ruby/vendor_ruby/action_view/locale/en.yml",
  + "/usr/lib/ruby/vendor_ruby/../locales/en.yml",
    "/usr/share/redmine/config/locales/en.yml",
  + "/usr/share/redmine/plugins/redmine_dmsf/config/locales/en.yml"

Reporting this to the module's author[2] did not lead to any helpful answer
yet. The same issue has been reported before[3] together with a different
bug that has been fixed.
I am pretty sure that this issue is thightly related to the redmine_dmsf
plugin as other plugins do not show that behavior...

I created a workaround for the issue (see attached patch) that checks if a
translation exists before loading it.

I hope you can help me find a better solution!

-- Adi

[1] https://github.com/danmunn/redmine_dmsf
[2] https://github.com/danmunn/redmine_dmsf/issues/354
[3] https://github.com/danmunn/redmine_dmsf/issues/288
--- a/redmine/lib/redmine/i18n.rb	2014-03-29 17:56:41.000000000 +0100
+++ b/redmine/lib/redmine/i18n.rb	2015-02-20 20:12:41.381991935 +0100
@@ -148,7 +148,7 @@
 
         def init_translations(locale)
           locale = locale.to_s
-          paths = ::I18n.load_path.select {|path| File.basename(path, '.*') == locale}
+          paths = ::I18n.load_path.select {|path| File.basename(path, '.*') == locale && File.exists?(path)}
           load_translations(paths)
           translations[locale] ||= {}
         end

Attachment: signature.asc
Description: Digital signature

Reply via email to