Project

General

Profile

Defect #1405

Macro not working in email notification

Added by Leith Caldwell over 3 years ago. Updated 4 months ago.

Status:
新規(New)
Priority:
高め(High)
Category:
-
Target version:
-
Start date:
03/01/2016
Due date:
% Done:

0%

Estimated time:

Description

Adding the ref_issues macro to news items works perfectly for displaying news in the browser, however when the email notifications are sent out for those news items, I get this error:

Error executing the ref_issues macro (undefined method `session' for #
/usr/local/bundle/gems/actionpack-3.2.22/lib/action_view/helpers/controller_helper.rb:10:in `session')

This is the macro usage I am using:

{{ref_issues(-f:status_id = 5, -f:updated_on >< 2016-02-23|2016-02-29, -f:tracker_id = 1|2|6, project, tracker, subject, cf_12)}}

History

#1

Updated by Tomohisa Kusukawa almost 3 years ago

  • Target version deleted (0.0.7)
#2

Updated by Leith Caldwell almost 3 years ago

Kusukawa-san, is there something I can do to help you track this down?

#3

Updated by Tomohisa Kusukawa almost 3 years ago

I'm sorry.
I have been investigating several times, but any solution has not been found.

#4

Updated by Satoru Ichioka 4 months ago

Wiki Listsをいつも便利に利用させていただいています。
私もチケット更新メール通知時のみ同様のエラーが出ているためご報告です。
ワークアラウンドなど対策方法あればご教示いただけると幸いです。

エラーメッセージ(抜粋)

Error executing the ref_issues macro (undefined method `session' for #
/var/lib/redmine/vendor/bundle/ruby/2.4.0/gems/actionview-4.2.8/lib/action_view/helpers/controller_helper.rb:10:in `session'
/var/lib/redmine/app/helpers/sort_helper.rb:93:in `sort_clear'
/var/lib/redmine/plugins/redmine_wiki_lists/lib/redmine_wiki_lists/ref_issues.rb:52:in `block (2 levels) in '
・・・(以下略)

ref_issuesマクロはチケットの説明欄に記載しています。
メール通知時以外は問題なく動作しています。

{{ref_issues(-i=109, -f:cf_71 = [subject])}}

Redmine環境は以下の通りです。

Environment:
  Redmine version                3.4.6.stable.17443
  Ruby version                   2.4.4-p296 (2018-03-28) [x86_64-linux]
  Rails version                  4.2.8
  Environment                    production
  Database adapter               Mysql2

Redmine plugins:
 ・・・
  redmine_wiki_lists             0.0.9
#5

Updated by Leith Caldwell 4 months ago

Kusukawa-san, just revisiting this a little...

So ref_issues.rb calls sort_clear:
https://www.r-labs.org/projects/wiki_lists/repository/63/revisions/master/entry/lib/redmine_wiki_lists/ref_issues.rb#L52

sort_clear is a pretty simple Redmine helper:
https://github.com/redmine/redmine/blob/7aa642ad7acbf40083b4e870acf8aa71d27eb0e9/app/helpers/sort_helper.rb#L92

The call to session triggers a call to the controller_helper in Rails:
https://github.com/rails/rails/blob/4-2-stable/actionview/lib/action_view/helpers/controller_helper.rb#L10

So apparently :session is an undefined delegated method in this context.

According to this SO answer:

[...] session is only available in context of controllers and views.

This is backed up by this SO answer as well.

Redmine's email notifications generated from posting news are triggered from the context of a class (ActionMailer), rather than a controller/view. This would be why the in-page version (using controller/view) still works just fine.

This SO question has a lot of discussion around this topic. It looks like you just need to include or extend the ApplicationHelper?

Also available in: Atom PDF