Bug 36158

Summary: Text on the "Show SQL code" button at guided_reports.pl breaks if report notice templates exist
Product: Koha Reporter: Jason Robb <jrobb>
Component: TemplatesAssignee: Pedro Amorim <pedro.amorim>
Status: RESOLVED FIXED QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: trivial    
Priority: P5 - low CC: caroline.cyr-la-rose, cbrannon, fridolin.somers, julian.maurice, kyle, lucas, martin.renvoize, pedro.amorim
Version: MainKeywords: Sandbox
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36297
Change sponsored?: --- Patch complexity: String patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.05.00,23.11.04
Circulation function:
Bug Depends on: 34136    
Bug Blocks: 36297, 36157    
Attachments: Broken text on 'Show SQL code' button
Bug 36158: Update t iterator variable
Bug 36158: Update t iterator variable
Bug 36158: Update t iterator variable

Description Jason Robb 2024-02-23 15:15:42 UTC
Created attachment 162386 [details]
Broken text on 'Show SQL code' button

When a report notice template exists (using the feature added in bug 34136), if you click the "Show SQL code" button after running a report the text on the button changes to something like "Koha::Notice::Template=HASH(xxxxx)"

To replicate:
- Create a notice with the module of "Reports" -- add something to the "Print" section. Example from the other bug:

[% FOREACH b IN data %]
<div class="panel panel-default">
  <div class="panel-heading">[% b.surname %], [% b.firstname %]</div>
  <div class="panel-body">Expiration: [% b.dateexpiry %]</div>
  <div class="panel-footer">ID: [% b.borrowernumber %]</div>
</div>
[% END %]

- Create and run a saved report. Example from the other bug:

SELECT * FROM borrowers

- Click the "Show SQL code" button
Comment 1 Pedro Amorim 2024-02-23 16:15:16 UTC
Created attachment 162389 [details] [review]
Bug 36158: Update t iterator variable

It seems like its causing some sort of conflict with t('Hide SQL code') further down below in the code, but I'm not sure why.
Comment 2 Kyle M Hall (khall) 2024-02-23 16:43:29 UTC
Created attachment 162393 [details] [review]
Bug 36158: Update t iterator variable

It seems like its causing some sort of conflict with t('Hide SQL code') further down below in the code, but I'm not sure why.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 3 Martin Renvoize (ashimema) 2024-02-29 10:24:32 UTC
Created attachment 162581 [details] [review]
Bug 36158: Update t iterator variable

It seems like its causing some sort of conflict with t('Hide SQL code') further down below in the code, but I'm not sure why.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize (ashimema) 2024-02-29 10:24:52 UTC
Trivial fix, clear code.. Passing QA
Comment 5 Katrin Fischer 2024-03-07 14:04:49 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 6 Fridolin Somers 2024-03-11 09:20:55 UTC
Pushed to 23.11.x for 23.11.04
Comment 7 Fridolin Somers 2024-03-11 09:22:09 UTC
(In reply to Martin Renvoize from comment #3)
> Created attachment 162581 [details] [review] [review]
> Bug 36158: Update t iterator variable
> 
> It seems like its causing some sort of conflict with t('Hide SQL code')
> further down below in the code, but I'm not sure why.
> 
> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Arf there are other places with a var named "t" in TT :

 > git grep 'FOREACH t IN'
origin/master:koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt:                                [%- FOREACH t IN [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] -%]
origin/master:koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt:                                                            [%- FOREACH t IN [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] -%]
origin/master:koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt:                        [% FOREACH t IN item_templates.owned %]
origin/master:koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt:                        [% FOREACH t IN item_templates.shared %]
origin/master:koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt:                    [% FOREACH t IN item_templates.owned %]
origin/master:koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt:                            [% FOREACH t IN item_templates.shared %]
origin/master:koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt:                                [% FOREACH t IN club_templates %]
origin/master:koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs.tt:                                [% FOREACH t IN club_templates %]
origin/master:koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt:                                    [% FOREACH t IN terms %]
Comment 8 Pedro Amorim 2024-03-11 12:43:04 UTC
Frido can you open a bug for this (if not already).
I think it would also be interesting to understand why the conflict happens in the first place, as one would think "for t in templates" would only consider a 't' variable inside the "for" loop.
But this was causing an issue somewhere else entirely in the code if I remember correctly.
Comment 9 Kyle M Hall (khall) 2024-03-11 13:52:50 UTC
(In reply to Pedro Amorim from comment #8)
> Frido can you open a bug for this (if not already).
> I think it would also be interesting to understand why the conflict happens
> in the first place, as one would think "for t in templates" would only
> consider a 't' variable inside the "for" loop.
> But this was causing an issue somewhere else entirely in the code if I
> remember correctly.

I've filed a bug report for Template Toolkit: https://github.com/abw/Template2/issues/317

Kyle
Comment 10 Fridolin Somers 2024-03-12 09:20:15 UTC
Created bug 36297
Comment 11 Lucas Gass (lukeg) 2024-03-19 15:07:50 UTC
Missing 23.05.x dependencies, no backport.
Comment 12 Christopher Brannon 2024-08-06 22:17:20 UTC
I'm in 24.05.02 and I can't get the Show SQL code to work on anything running in a template.  Am I misunderstanding?