Bug 36158 - Text on the "Show SQL code" button at guided_reports.pl breaks if report notice templates exist
Summary: Text on the "Show SQL code" button at guided_reports.pl breaks if report noti...
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low trivial (vote)
Assignee: Pedro Amorim
QA Contact: Martin Renvoize
URL:
Keywords: Sandbox
Depends on: 34136
Blocks: 36297 36157
  Show dependency treegraph
 
Reported: 2024-02-23 15:15 UTC by Jason Robb
Modified: 2024-03-19 15:07 UTC (History)
7 users (show)

See Also:
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


Attachments
Broken text on 'Show SQL code' button (17.06 KB, image/png)
2024-02-23 15:15 UTC, Jason Robb
Details
Bug 36158: Update t iterator variable (1.72 KB, patch)
2024-02-23 16:15 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 36158: Update t iterator variable (1.77 KB, patch)
2024-02-23 16:43 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 36158: Update t iterator variable (1.84 KB, patch)
2024-02-29 10:24 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 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 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 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 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 2024-03-19 15:07:50 UTC
Missing 23.05.x dependencies, no backport.