alvila / redmine_reminder

http://www.alvila.com/
54 stars 25 forks source link

undefined method `+' for nil:NilClass #8

Open jrevillard opened 13 years ago

jrevillard commented 13 years ago

Hi,

I'm using redmine 1.2.1 without problem with your problem until I start to completely remove old users (not only desactivated... removed). Your plugin generate this kind of trace:

root@web /usr/local/lib/redmine # cd /usr/local/lib/redmine && rake --trace redmine:send_reminders_all days=14 RAILS_ENV=production
(in /usr/local/lib/redmine-1.2.1)
** Invoke redmine:send_reminders_all (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute redmine:send_reminders_all
rake aborted!
undefined method `+' for nil:NilClass
/usr/local/lib/redmine-1.2.1/vendor/plugins/redmine_reminder/lib/tasks/reminder_all.rake:111:in `reminders_all'
/usr/local/lib/redmine-1.2.1/vendor/plugins/redmine_reminder/lib/tasks/reminder_all.rake:111:in `sort!'
/usr/local/lib/redmine-1.2.1/vendor/plugins/redmine_reminder/lib/tasks/reminder_all.rake:111:in `reminders_all'
/usr/local/lib/redmine-1.2.1/vendor/plugins/redmine_reminder/lib/tasks/reminder_all.rake:171
/usr/lib/ruby/1.8/rake.rb:636:in `call'
/usr/lib/ruby/1.8/rake.rb:636:in `execute'
/usr/lib/ruby/1.8/rake.rb:631:in `each'
/usr/lib/ruby/1.8/rake.rb:631:in `execute'
/usr/lib/ruby/1.8/rake.rb:597:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/1.8/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/rake.rb:583:in `invoke'
/usr/lib/ruby/1.8/rake.rb:2051:in `invoke_task'
/usr/lib/ruby/1.8/rake.rb:2029:in `top_level'
/usr/lib/ruby/1.8/rake.rb:2029:in `each'
/usr/lib/ruby/1.8/rake.rb:2029:in `top_level'
/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:2023:in `top_level'
/usr/lib/ruby/1.8/rake.rb:2001:in `run'
/usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/1.8/rake.rb:1998:in `run'
/usr/bin/rake:28

The problem is that redmine automatically assign the issues that were created by this user to the Anonymous one... which don't have any email address of course.

I simply corrected the issue with this simple patch:

diff --git a/lib/tasks/reminder_all.rake b/lib/tasks/reminder_all.rake
index 35e83d2..5ad0335 100644
--- a/lib/tasks/reminder_all.rake
+++ b/lib/tasks/reminder_all.rake
@@ -90,7 +90,9 @@ class Reminder_all < Mailer
        end
       end
       if found==0 then
-       over_due<<[author, "author", issues]
+        if !author.mail.nil? then
+         over_due<<[author, "author", issues]
+       end
       end
     end
     issues_by.group_by(&:watchers).each do |watchers, issues|

All the best, Jérôme

jdkoelsch commented 12 years ago

I also encountered this issue, and the patch above fixed the issue for me. Thanks, Jerome!