Defect #15105
closed
Redmine::Helpers::Diff missing require
Added by Felix Bünemann about 11 years ago.
Updated about 11 years ago.
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
- Status changed from New to Needs feedback
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'
- Status changed from Needs feedback to Closed
Committed in trunk r12206, thanks.
Also available in: Atom
PDF