Defect #3672

Unable to set "value" and "old_value" through :helper_issues_show_detail_after_setting hook

Added by Giovanni Junior over 12 years ago. Updated almost 9 years ago.

Status:NewStart date:2009-07-25
Priority:NormalDue date:
Assignee:-% Done:


Category:Plugin API
Target version:-
Resolution: Affected version:0.8.4


In, the description for :helper_issues_show_detail_after_setting states that it "Passes data to the hook to allow it to set the label and value", but it seems this is only partially true.

Setting context variables in a hook using the "=" operand just doesn't work. For "context[:label]", which is already initialized (as a String) when the hook is called, this may be worked around calling "context[:label].replace". However, as "context[:value]" and "context[:old_value]" may be uninitialized when the hook is called, I don't see a way to change their value at all. And setting "context[:detail].value" and "context[:detail].old_value" is obviously not as harmless as setting "context[:value]" and "context[:old_value]".

Using Redmine 0.8.4, Rails 2.1.2 and Ruby 1.8.6.

issues_helper.rb.patch Magnifier (844 Bytes) Thomas Löber, 2010-02-19 13:39


#1 Updated by Eric Davis about 12 years ago

Can you attach a test case showing this? I've been able to set context[:value] and context[:old_value] in my Budget plugin:

#2 Updated by Giovanni Junior about 12 years ago

Your plugin sets context[:detail].value and context[:detail].old_value, which are different from context[:value] and context[:old_value].

Unfortunately, the code in question is not very "testable". Indeed, I have no idea how to test it.

#3 Updated by Eric Davis over 11 years ago

  • Status changed from New to 7

I just ran into this myself. Setting context[:object] to a new object isn't sent back to the calling code (new object reference). Setting context[:object].value works because :object is still the same object.

I've worked around this in some private code but it wasn't an easy implementation. I think we might need to split how the View Hooks return data from the Model/Controller hooks (View should merge the response strings, Model/Controller should check for reassignments).

#4 Updated by Thomas Löber over 11 years ago

I worked around it by adding another hook for plugin-defined detail properties (see issues_helper.rb.patch for Redmine 0.9-stable).

Then the hook code would look like this:

    def helper_issues_show_detail_format(context)
      detail = context[:detail]
      if == "user_notified" 
        user = User.find_by_id(detail.prop_key) or return
        l(:label_user_notified, context[:html] ? link_to_user(user) :

#5 Updated by Pascal Schoenhardt over 11 years ago

Couldn't this issue be fixed quite easily by assigning the value, old_value, and label defaults before calling the hook in app/helpers/issues_helper.rb?


    call_hook(:helper_issues_show_detail_after_setting, {:detail => detail, :label => label, :value => value, :old_value => old_value })

    label ||= detail.prop_key
    value ||= detail.value
    old_value ||= detail.old_value


    label ||= detail.prop_key
    value ||= detail.value
    old_value ||= detail.old_value

    call_hook(:helper_issues_show_detail_after_setting, {:detail => detail, :label => label, :value => value, :old_value => old_value })

Now the objects are initialized, and the if the hook modifies them it will get passed back.

#6 Updated by Eric Davis almost 11 years ago

  • Assignee deleted (Eric Davis)

I am stepping down from working on Redmine. If someone else is interesting in working on this issue, feel free to reassign it to them.

Eric Davis

#7 Updated by Jean-Philippe Lang almost 9 years ago

  • Status changed from 7 to New

Assigned issue with no assignee back to New status.

Also available in: Atom PDF