Bug 33030 - Add standardized subroutine for processing Template Toolkit syntax outside of notices
Summary: Add standardized subroutine for processing Template Toolkit syntax outside of...
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor (vote)
Assignee: Kyle M Hall
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on: 33039
Blocks: 33043 33041 33045 33046 34136
  Show dependency treegraph
 
Reported: 2023-02-21 18:05 UTC by Kyle M Hall
Modified: 2023-12-28 20:47 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.11.00


Attachments
Bug 33030: Add standardized subroutine for processing Template Toolkit syntax outside of notices (4.41 KB, patch)
2023-02-21 19:18 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 33030: Add standardized subroutine for processing Template Toolkit syntax outside of notices (3.92 KB, patch)
2023-02-22 19:53 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 33030: Add unit tests (2.16 KB, patch)
2023-03-10 15:20 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 33030: Add standardized subroutine for processing Template Toolkit syntax outside of notices (3.96 KB, patch)
2023-05-02 11:06 UTC, David Nind
Details | Diff | Splinter Review
Bug 33030: Add unit tests (2.21 KB, patch)
2023-05-02 11:06 UTC, David Nind
Details | Diff | Splinter Review
Bug 33030: Add standardized subroutine for processing Template Toolkit syntax outside of notices (4.06 KB, patch)
2023-07-07 09:52 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 33030: Add unit tests (2.30 KB, patch)
2023-07-07 09:52 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall 2023-02-21 18:05:09 UTC
Koha has evolved to use Template Toolkit for many uses outside of generating slips and notices for patrons. Historically, each of these areas processed template toolkit in a slightly different way. We should add a module to allow Template Toolkit syntax to be processed in a standard and generic way such that all non-notice TT syntax is handled and processed the consistently.
Comment 1 Kyle M Hall 2023-02-21 19:18:20 UTC
Created attachment 147085 [details] [review]
Bug 33030: Add standardized subroutine for processing Template Toolkit syntax outside of notices

Koha has evolved to use Template Toolkit for many uses outside of generating slips and notices for patrons. Historically, each of these areas processed template toolkit in a slightly different way. We should add a module to allow Template Toolkit syntax to be processed in a standard and generic way such that all non-notice TT syntax is handled and processed the consistently.

Test Plan:
1) Apply this patch
2) prove t/db_dependent/Letters/TemplateToolkit.t
Comment 2 Kyle M Hall 2023-02-22 19:53:38 UTC
Created attachment 147182 [details] [review]
Bug 33030: Add standardized subroutine for processing Template Toolkit syntax outside of notices

Koha has evolved to use Template Toolkit for many uses outside of generating slips and notices for patrons. Historically, each of these areas processed template toolkit in a slightly different way. We should add a module to allow Template Toolkit syntax to be processed in a standard and generic way such that all non-notice TT syntax is handled and processed the consistently.

Test Plan:
1) Apply this patch
2) prove t/db_dependent/Koha/Items.t
Comment 3 Kyle M Hall 2023-03-10 15:20:26 UTC
Created attachment 148076 [details] [review]
Bug 33030: Add unit tests
Comment 4 David Nind 2023-05-02 02:27:09 UTC
The tests currently fail:

prove t/db_dependent/Koha/Items.t
t/db_dependent/Koha/Items.t .. 6/16     # Looks like you planned 9 tests but ran 4.
t/db_dependent/Koha/Items.t .. 15/16 
#   Failed test 'search_ordered'
#   at t/db_dependent/Koha/Items.t line 1904.
DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column 'published_on_template' in 'field list' at /kohadevbox/koha/t/lib/TestBuilder.pm line 384
# Looks like your test exited with 11 just after 15.
t/db_dependent/Koha/Items.t .. Dubious, test returned 11 (wstat 2816, 0xb00)
Failed 2/16 subtests 

Test Summary Report
-------------------
t/db_dependent/Koha/Items.t (Wstat: 2816 Tests: 15 Failed: 1)
  Failed test:  15
  Non-zero exit status: 11
  Parse errors: Bad plan.  You planned 16 tests but ran 15.
Files=1, Tests=15,  5 wallclock secs ( 0.04 usr  0.00 sys +  3.69 cusr  0.58 csys =  4.31 CPU)
Result: FAIL
Comment 5 Kyle M Hall 2023-05-02 10:53:05 UTC
(In reply to David Nind from comment #4)
> The tests currently fail:
> 
> prove t/db_dependent/Koha/Items.t

They are passing for me! Did you apply the dependency (Bug 33039) beforehand and run updatedatabase.pl? I get your error if I have applied both bugs but don't run updatedatabase.pl before running the unit tests.
Comment 6 David Nind 2023-05-02 11:06:07 UTC
Created attachment 150511 [details] [review]
Bug 33030: Add standardized subroutine for processing Template Toolkit syntax outside of notices

Koha has evolved to use Template Toolkit for many uses outside of generating slips and notices for patrons. Historically, each of these areas processed template toolkit in a slightly different way. We should add a module to allow Template Toolkit syntax to be processed in a standard and generic way such that all non-notice TT syntax is handled and processed the consistently.

Test Plan:
1) Apply this patch
2) prove t/db_dependent/Koha/Items.t

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 David Nind 2023-05-02 11:06:10 UTC
Created attachment 150512 [details] [review]
Bug 33030: Add unit tests

Signed-off-by: David Nind <david@davidnind.com>
Comment 8 David Nind 2023-05-02 11:07:04 UTC
(In reply to Kyle M Hall from comment #5)
> (In reply to David Nind from comment #4)
> > The tests currently fail:
> > 
> > prove t/db_dependent/Koha/Items.t
> 
> They are passing for me! Did you apply the dependency (Bug 33039) beforehand
> and run updatedatabase.pl? I get your error if I have applied both bugs but
> don't run updatedatabase.pl before running the unit tests.

It works with the updatedatabase - now signed off!
Comment 9 Kyle M Hall 2023-05-02 11:51:37 UTC
> It works with the updatedatabase - now signed off!

Thanks David!
Comment 10 Marcel de Rooy 2023-07-07 09:51:46 UTC
$processed = process_tt($template, $vars);

Process the given Template Toolkit string, passing the given hashref of vars to the template, returning the processed string.

It is written correctly. But when I see $template, I still think of a file..
Comment 11 Marcel de Rooy 2023-07-07 09:52:32 UTC
Created attachment 153142 [details] [review]
Bug 33030: Add standardized subroutine for processing Template Toolkit syntax outside of notices

Koha has evolved to use Template Toolkit for many uses outside of generating slips and notices for patrons. Historically, each of these areas processed template toolkit in a slightly different way. We should add a module to allow Template Toolkit syntax to be processed in a standard and generic way such that all non-notice TT syntax is handled and processed the consistently.

Test Plan:
1) Apply this patch
2) prove t/db_dependent/Koha/Items.t

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 12 Marcel de Rooy 2023-07-07 09:52:34 UTC
Created attachment 153143 [details] [review]
Bug 33030: Add unit tests

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 13 Tomás Cohen Arazi 2023-07-14 19:52:58 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 14 Jonathan Druart 2023-07-18 08:01:54 UTC
Can we stop with "Util" in package names please?
Comment 15 David Cook 2023-07-18 23:17:24 UTC
(In reply to Jonathan Druart from comment #14)
> Can we stop with "Util" in package names please?

I thought we did have a code guideline outlawing it but apparently we don't. Worth adding one for it I think.
Comment 16 Martin Renvoize 2023-07-19 08:20:50 UTC
Holding off on backport here thinking we may want to change the module name ;P