Defect #4188
closedgantt.rhtml doesn't correctly handle nil values
0%
Description
Method due_before in app/models/issue.rb can return nil.
app/views/gantt.rhtml doesn't handle this case correctly, instead exiting with the following error:
ActionView::TemplateError (undefined method `<=' for nil:NilClass) on line #184 of issues/gantt.rhtml
This can happen if an issue has a due_date of 0000-00-00 and no fixed_version.
Environment information:
Database Version mysql Ver 14.12 Distrib 5.0.67, for suse-linux-gnu (x86_64) using readline 5.2 Ruby version 1.8.7 (x86_64-linux) Rails version 2.1.2
Error log entry:
ActionView::TemplateError (undefined method `<=' for nil:NilClass) on line #184 of issues/gantt.rhtml: 181: @gantt.events.each do |i| 182: if i.is_a? Issue 183: i_start_date = (i.start_date >= @gantt.date_from ? i.start_date : @gantt.date_from ) 184: i_end_date = (i.due_before <= @gantt.date_to ? i.due_before : @gantt.date_to ) 185: 186: i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor 187: i_done_date = (i_done_date <= @gantt.date_from ? @gantt.date_from : i_done_date ) app/views/issues/gantt.rhtml:184:in `_run_erb_47app47views47issues47gantt46rhtml' app/views/issues/gantt.rhtml:181:in `each' app/views/issues/gantt.rhtml:181:in `_run_erb_47app47views47issues47gantt46rhtml' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/base.rb:342:in `send' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/base.rb:342:in `execute' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/template_handlers/compilable.rb:29:in `send' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/template_handlers/compilable.rb:29:in `render' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/template.rb:35:in `render' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/template.rb:22:in `render_template' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/base.rb:248:in `render_file' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/base.rb:1112:in `render_for_file' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/base.rb:872:in `render_with_no_layout' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/layout.rb:251:in `render_without_benchmark' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/benchmarking.rb:51:in `render' /usr/lib64/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/core_ext/benchmark.rb:8:in `realtime' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/benchmarking.rb:51:in `render' app/controllers/issues_controller.rb:355:in `gantt' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/mime_responds.rb:131:in `call' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/mime_responds.rb:131:in `custom' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/mime_responds.rb:160:in `call' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/mime_responds.rb:160:in `respond' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/mime_responds.rb:154:in `each' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/mime_responds.rb:154:in `respond' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/mime_responds.rb:107:in `respond_to' app/controllers/issues_controller.rb:354:in `gantt' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/base.rb:1166:in `send' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/base.rb:1166:in `perform_action_without_filters' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/filters.rb:579:in `call_filters' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/filters.rb:572:in `perform_action_without_benchmark' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' /usr/lib64/ruby/1.8/benchmark.rb:293:in `measure' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/rescue.rb:201:in `perform_action_without_caching' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/caching/sql_cache.rb:13:in `perform_action' /usr/lib64/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache' /usr/lib64/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/query_cache.rb:8:in `cache' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/caching/sql_cache.rb:12:in `perform_action' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/base.rb:529:in `send' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/base.rb:529:in `process_without_filters' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/filters.rb:568:in `process_without_session_management_support' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/session_management.rb:130:in `process' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/base.rb:389:in `process' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:149:in `handle_request' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:107:in `dispatch' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:104:in `synchronize' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:104:in `dispatch' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:35:in `dispatch' /usr/lib64/ruby/gems/1.8/gems/rails-2.1.2/lib/fcgi_handler.rb:103:in `process_request' /usr/lib64/ruby/gems/1.8/gems/rails-2.1.2/lib/fcgi_handler.rb:153:in `with_signal_handler' /usr/lib64/ruby/gems/1.8/gems/rails-2.1.2/lib/fcgi_handler.rb:101:in `process_request' /usr/lib64/ruby/gems/1.8/gems/rails-2.1.2/lib/fcgi_handler.rb:78:in `process_each_request' /usr/lib64/ruby/vendor_ruby/1.8/fcgi.rb:612:in `each_cgi' /usr/lib64/ruby/vendor_ruby/1.8/fcgi.rb:609:in `each' /usr/lib64/ruby/vendor_ruby/1.8/fcgi.rb:609:in `each_cgi' /usr/lib64/ruby/gems/1.8/gems/rails-2.1.2/lib/fcgi_handler.rb:77:in `process_each_request' /usr/lib64/ruby/gems/1.8/gems/rails-2.1.2/lib/fcgi_handler.rb:76:in `catch' /usr/lib64/ruby/gems/1.8/gems/rails-2.1.2/lib/fcgi_handler.rb:76:in `process_each_request' /usr/lib64/ruby/gems/1.8/gems/rails-2.1.2/lib/fcgi_handler.rb:50:in `process!' /usr/lib64/ruby/gems/1.8/gems/rails-2.1.2/lib/fcgi_handler.rb:24:in `process!' public/dispatch.fcgi:24 Rendering /srv/www/vhosts/redmine-0.8/public/500.html (500 Internal Server Error)
Updated by Jean-Philippe Lang over 15 years ago
This can happen if an issue has a due_date of 0000-00-00
How did you create this issue?
Entering '0000-00-00' as the due date in the issue form does not validate.
Updated by Marcus Fellinger over 15 years ago
By using ralli's Bugzilla to Redmine converter at
http://github.com/ralli/bz2redmine/blob/cb2b7549a4902157a6a022b686e9115a3a9fabb8/bz2redmine.rb
So there are two problems
1. The converter creates invalid issues, and it should be fixed to assign a sensible due_date to the imported issues.
2. Data coming from the database is external data, just as data entered by the user is, and has to checked for validity before use.
Updated by Jean-Philippe Lang over 15 years ago
- Status changed from New to Closed
- Resolution set to Wont fix
This converter do manual INSERTs into the Redmine database and thus, data do not go through the validations.
You may want to report this problem to the author of this converter.
Anyway, you can fix the due dates with something like:
UPDATE issues SET due_date = NULL WHERE due_date = '0000-00-00'