Defect #33103

Export to PDF fails when subject of parent task is included in issue list

Added by Immanuel Wilhelmy about 1 month ago. Updated 13 days ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:PDF export
Target version:4.1.1
Resolution:Fixed Affected version:4.1.0

Description

Description

When choosing the subject of parent tasks to be displayed in the issue list, the pdf export fails and the user get's the "internal error" site presented.

Log file output

ActionView::Template::Error (undefined method `parent.subject' for #<Issue:0x00000000069ba248>
Did you mean?  parent_issue_id):
    1: <%= raw issues_to_pdf(@issues, @project, @query) %>

lib/redmine/export/pdf/issues_pdf_helper.rb:378:in `block in fetch_row_values'
lib/redmine/export/pdf/issues_pdf_helper.rb:372:in `collect'
lib/redmine/export/pdf/issues_pdf_helper.rb:372:in `fetch_row_values'
lib/redmine/export/pdf/issues_pdf_helper.rb:435:in `block in calc_col_width'
app/helpers/issues_helper.rb:31:in `block in issue_list'
app/helpers/issues_helper.rb:26:in `each'
app/helpers/issues_helper.rb:26:in `issue_list'
lib/redmine/export/pdf/issues_pdf_helper.rb:433:in `calc_col_width'
lib/redmine/export/pdf/issues_pdf_helper.rb:278:in `issues_to_pdf'
app/views/issues/index.pdf.erb:1:in `_26913a66e609d0514246c7dc3391de38'
lib/redmine/sudo_mode.rb:65:in `sudo_mode'

ActionView::Template::Error (undefined method `parent.subject' for #<Issue:0x0000000008b17468>
Did you mean?  parent_issue_id):
    1: <%= raw issues_to_pdf(@issues, @project, @query) %>

lib/redmine/export/pdf/issues_pdf_helper.rb:378:in `block in fetch_row_values'
lib/redmine/export/pdf/issues_pdf_helper.rb:372:in `collect'
lib/redmine/export/pdf/issues_pdf_helper.rb:372:in `fetch_row_values'
lib/redmine/export/pdf/issues_pdf_helper.rb:435:in `block in calc_col_width'
app/helpers/issues_helper.rb:31:in `block in issue_list'
app/helpers/issues_helper.rb:26:in `each'
app/helpers/issues_helper.rb:26:in `issue_list'
lib/redmine/export/pdf/issues_pdf_helper.rb:433:in `calc_col_width'
lib/redmine/export/pdf/issues_pdf_helper.rb:278:in `issues_to_pdf'
app/views/issues/index.pdf.erb:1:in `_26913a66e609d0514246c7dc3391de38'
lib/redmine/sudo_mode.rb:65:in `sudo_mode'

The csv export of the same list works fine.

33103.patch Magnifier (1.67 KB) Yuichi HARADA, 2020-03-23 07:13


Related issues

Related to Redmine - Feature #19371: Add a new query column for the parent task subject Closed

Associated revisions

Revision 19611
Added by Go MAEDA 13 days ago

Export to PDF fails when subject of parent task is included in issue list (#33103).

Patch by Marius BALTEANU and Yuichi HARADA.

Revision 19612
Added by Go MAEDA 13 days ago

Merged r19611 from trunk to 4.1-stable (#33103).

History

#1 Updated by Go MAEDA about 1 month ago

  • Status changed from New to Confirmed

#2 Updated by Go MAEDA about 1 month ago

  • Related to Feature #19371: Add a new query column for the parent task subject added

#3 Updated by Yuichi HARADA 14 days ago

This will be resolved with the following patch.

diff --git a/lib/redmine/export/pdf/issues_pdf_helper.rb b/lib/redmine/export/pdf/issues_pdf_helper.rb
index 2f73e52a4..4b06fb87c 100644
--- a/lib/redmine/export/pdf/issues_pdf_helper.rb
+++ b/lib/redmine/export/pdf/issues_pdf_helper.rb
@@ -379,7 +379,11 @@ module Redmine
                 cv = issue.visible_custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
                 show_value(cv, false)
               else
-                value = issue.send(column.name)
+                value = issue
+                column.name.to_s.split(/\./).each do |column_name|
+                  value = value.__send__(column_name)
+                  break unless value
+                end
                 case column.name
                 when :subject
                   value = "  " * level + value

#4 Updated by Marius BALTEANU 13 days ago

  • Target version set to 4.1.1

Yuichi HARADA, I think we can fix the issue by using the method column.value_object(issue) instead of issue.send(). What do you think?

diff --git a/lib/redmine/export/pdf/issues_pdf_helper.rb b/lib/redmine/export/pdf/issues_pdf_helper.rb
index 2f73e52a4..b49691695 100644
--- a/lib/redmine/export/pdf/issues_pdf_helper.rb
+++ b/lib/redmine/export/pdf/issues_pdf_helper.rb
@@ -379,7 +379,7 @@ module Redmine
                 cv = issue.visible_custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
                 show_value(cv, false)
               else
-                value = issue.send(column.name)
+                value = column.value_object(issue)
                 case column.name
                 when :subject
                   value = "  " * level + value

I've added your test to this fix and it looks good on CI: https://gitlab.com/redmine-org/redmine/pipelines/128961861

#5 Updated by Yuichi HARADA 13 days ago

Marius BALTEANU wrote:

Yuichi HARADA, I think we can fix the issue by using the method column.value_object(issue) instead of issue.send(). What do you think?

[...]

I've added your test to this fix and it looks good on CI: https://gitlab.com/redmine-org/redmine/pipelines/128961861

I agree with you, I think it is correct. I didn't understand the method QueryColumn#value_object.

#6 Updated by Go MAEDA 13 days ago

  • Status changed from Confirmed to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you all for reporting and fixing the issue.

Also available in: Atom PDF