Defect #15105
closedRedmine::Helpers::Diff missing require
0%
Description
The lib/redmine/helpers/diff.rb
is missing a require 'diff'
to load lib/diff.rb
so it fails to call diff on an array in inititialize:
>> Redmine::Helpers::Diff.new("foo", "bar")
NoMethodError: undefined method `diff' for ["foo", "bar"]:Array
This can be reproduced by changing the description of an issue and then clicking on the diff link.
Files
Updated by Felix Bünemann about 11 years ago
- File redmine_diff_fix.patch redmine_diff_fix.patch added
Updated by Toshi MARUYAMA about 11 years ago
- Status changed from New to Needs feedback
Felix Bünemann wrote:
This can be reproduced by changing the description of an issue and then clicking on the diff link.
I cannot reproduce on clean Redmine.
"lib" is autoload.
source:trunk/config/application.rb@12204#L19
Updated by Felix Bünemann about 11 years ago
But it is a Monkey-Patch to the Array class, so how does autoloading help? We're not using the RedmineDiff::Diff class directly, so there is no trigger for autoloading. Besides that the file lib/diff.rb
doesn't even follow conventions for autoloading in rails, because it defines multiple modules that don't match the file name.
It probably can't be reproduced, if for some reason the require 'diff' has already happened by another controller:
app/controllers/wiki_controller.rb:18:require 'diff' app/models/wiki_page.rb:18:require 'diff'
For a simpler way to reproduce just use the rails console:
>> Redmine::Helpers::Diff.new("foo", "bar") NoMethodError: undefined method `diff' for ["bar"]:Array from lib/redmine/helpers/diff.rb:33:in `initialize'
Updated by Toshi MARUYAMA about 11 years ago
- Status changed from Needs feedback to Closed
Committed in trunk r12206, thanks.