https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43395

--- Comment #6 from Lisette Scheer <[email protected]> ---
Created attachment 211797
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211797&action=edit
Bug 43395: (follow-up) Check hash keys, loops without a variable and plugin
content

- A code listed in the registry only receives the variables of its own
  entry, so e.g. using overdues on SR_SLIP is now reported. Custom codes
  (created in the notices tool, e.g. for the overdue notice triggers)
  still get those of every sender of the module.
- Keys of known hashes (bug 36588's follow-up) are checked: an unknown
  key is reported as a warning (unknown_key).
- [% FOREACH list %] (without a loop variable) no longer reports
  "import is not available to this notice".
- plugin_content is checked against the enabled plugins implementing the
  notices_content hook: an unknown namespace is a warning.
- A lowercase directive (bug 39716's follow-up) isn't also reported as an
  unknown variable.
- A variable assigned values of different types, or a value of another
  type than the notice passes, is no longer checked against one of them:
  e.g. [% WHILE (item = overdues.next) %][% item.date_due %] in an
  overdue notice, which also receives item, reported an error, so a
  notice that works could not be saved.
- Arguments of macros, and parameters of INCLUDE and PROCESS, are
  variables: [% MACRO m(a) BLOCK %][% a.b %][% END %] no longer reports a.
- The virtual methods of hashes are the ones Template Toolkit has, with
  those of lists (e.g. branch.empty, branch.first), not unknown keys.
- Checking long templates is faster: the lines of the problems are
  found once for the whole template.
- Koha::Notice::Template loads the validator when it checks a template
  only, as C4::Letters uses it.

"and N more" in the list of unknown variables is translated with
plural forms.

Test plan:
1. Apply the patch, run yarn build and restart_all
2. Edit SR_SLIP and add [% FOREACH overdue IN overdues %][% END %]
3. Save: overdues is reported as not available to this notice
4. Replace it with [% branch.nom %]: a warning lists the keys of branch
5. Add [% FOREACH branch.items %][% END %]: no problem about "import"
6. Add [% plugin_content.nothing.x %]: a warning lists the plugins
   adding content (none if no such plugin is enabled)
7. Edit ODUE and add [% SET item = overdues.next %][% item.date_due %]
   and [% MACRO m(a) BLOCK %][% a.b %][% END %]:
   => No problem is reported
8. prove t/db_dependent/Koha/Notice/Template/Validator.t \
         t/db_dependent/Koha/Notice/Template/Variables.t

Co-Authored-By: Claude Opus 5.5 <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to