Vote #65554
完了Custom Values with a nil value cause HTTP error 500
0%
説明
I recently upgraded my Redmine installation from r2264 to r2835. The upgrade and database migration went without a hitch.
However, most - but not all - of my project pages stopped working. The log states:
bc. ActionView::TemplateError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.empty?) on line #12 of app/views/projects/show.rhtml:
9: <%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %>
10: <% end %>
11: <% @project.custom_values.each do |custom_value| %>
12: <% if !custom_value.value.empty? %>
13:
14: <% end %>
15: <% end %>
Digging into my data it appears that all the Projects whose page have stopped working have a bunch of CustomFields with a value of nil:
bc. >> Project.first.custom_values
=> [#
Both of those custom fields appear to have been added by the Redmine Hoptoad Server plugin at http://github.com/yeah/redmine_hoptoad_server/tree/master.
Anyways, seeing as there are no validations in RedMine on CustomValue preventing nil-values from being stored in the database, the projects/show.rhtml view is making unsafe assumptions. The attached patch adds a safeguard for the assumption.
The patch also fixes the issue reported in http://www.redmine.org/boards/2/topics/5872, which is basically the same issue as this.
journals
If you, as a Redmine user, want to work around this issue, the following method appears to be working:
1. Go to your Project administration area under Administration > Projects
2. Visit each project that has the above issue.
3. Click "Save".
This should fix the above issue (by replacing the nil-values with empty strings).
--------------------------------------------------------------------------------
Fixed in r2894. Thanks.
--------------------------------------------------------------------------------
Merged in 0.8-stable in r2996.
--------------------------------------------------------------------------------