[Bug 32453] New: Object methods _result and _resultset methods not available in templates
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 Bug ID: 32453 Summary: Object methods _result and _resultset methods not available in templates Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: minor Priority: P5 - low Component: Templates Assignee: oleonard@myacpl.org Reporter: kyle@bywatersolutions.com QA Contact: testopia@bugs.koha-community.org There are times where it would be really useful to be able to access the underying result or resultset within out templates. However, Template Toolkit itself disallows this, but you can disable this feature by setting the $Template::Stash::PRIVATE package variable to a false value. $Template::Stash::PRIVATE = undef; # now you can thing._private The alternate would be to rename _result and _resultset or just provide non-prefixed aliases as result and resultset respectively. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|oleonard@myacpl.org |kyle@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |WONTFIX --- Comment #1 from Kyle M Hall <kyle@bywatersolutions.com> --- If you really need to, you can add [% PERL %]$Template::Stash::PRIVATE = undef;[% END %] to the top of your notice to all access to those methods. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|WONTFIX |--- Status|RESOLVED |REOPENED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 --- Comment #2 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 150302 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=150302&action=edit Bug 32453: Allow template access to _result/_resultset There are times where it would be really useful to be able to access the underying result or resultset within out templates. However, Template Toolkit itself disallows this, but you can disable this feature by setting the $Template::Stash::PRIVATE package variable to a false value. Test Plan: 1) Modify the CHECKOUT notice, add "*[% biblio._result %]*" to your notice 2) Generate a CHECKOUT notice, note you only get "**" 3) Apply this patch 4) Restart all the things! 5) Generate a CHECKOUT notice, note you know get something like "*Koha::Schema::Result::Biblio=HASH(0x564f907a3390*" in your notice! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 Lucas Gass <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 Lucas Gass <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #150302|0 |1 is obsolete| | --- Comment #3 from Lucas Gass <lucas@bywatersolutions.com> --- Created attachment 150310 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=150310&action=edit Bug 32453: Allow template access to _result/_resultset There are times where it would be really useful to be able to access the underying result or resultset within out templates. However, Template Toolkit itself disallows this, but you can disable this feature by setting the $Template::Stash::PRIVATE package variable to a false value. Test Plan: 1) Modify the CHECKOUT notice, add "*[% biblio._result %]*" to your notice 2) Generate a CHECKOUT notice, note you only get "**" 3) Apply this patch 4) Restart all the things! 5) Generate a CHECKOUT notice, note you know get something like "*Koha::Schema::Result::Biblio=HASH(0x564f907a3390*" in your notice! Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |In Discussion CC| |m.de.rooy@rijksmuseum.nl --- Comment #4 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Not sure if we should go this way and put such constructs in our templates too. This needs a broader dev discussion. Please trigger it by mailing dev list or putting it on dev meeting agenda. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 --- Comment #5 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 200290 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200290&action=edit Bug 32453: (follow-up) Avoid 'used only once' warning for Template::Stash::PRIVATE Setting $Template::Stash::PRIVATE in C4::Templates triggers a 'Name "Template::Stash::PRIVATE" used only once: possible typo' warning, which makes xt/pl_valid.t fail on the file. Wrap the assignment in a 'no warnings ( q{once} )' block so the intentional single use no longer warns. Test plan: 1) Apply the main patch and this follow-up 2) prove xt/pl_valid.t 3) Note C4/Templates.pm no longer reports a 'used only once' warning -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 --- Comment #6 from David Cook <dcook@prosentient.com.au> --- (In reply to Marcel de Rooy from comment #4)
Not sure if we should go this way and put such constructs in our templates too. This needs a broader dev discussion. Please trigger it by mailing dev list or putting it on dev meeting agenda.
Yeah, I don't think this change makes sense. I'm sure there are times it would be useful to access private methods, but that should probably signal that we have some missing functionality. Are there any particular use cases in mind for this one? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 --- Comment #7 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- (In reply to David Cook from comment #6)
(In reply to Marcel de Rooy from comment #4)
Not sure if we should go this way and put such constructs in our templates too. This needs a broader dev discussion. Please trigger it by mailing dev list or putting it on dev meeting agenda.
Yeah, I don't think this change makes sense. I'm sure there are times it would be useful to access private methods, but that should probably signal that we have some missing functionality.
Are there any particular use cases in mind for this one?
The idea is to not populate our classes with functions used solely for the purpose of data being accessible from notice templates. A small handful of generic accessors would be better then a multitude of specific ones that we'd need to maintain without knowing if they are even being used. I'll try to find some specific use cases. It's worth noting now that template renders are wrapped in a rolled back transaction. An alternative would be to add public result and resultset accessors specifically instead of enabling access to all private accessors. Would that be a better solution? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 --- Comment #8 from David Cook <dcook@prosentient.com.au> --- (In reply to Kyle M Hall (khall) from comment #7)
The idea is to not populate our classes with functions used solely for the purpose of data being accessible from notice templates. A small handful of generic accessors would be better then a multitude of specific ones that we'd need to maintain without knowing if they are even being used. I'll try to find some specific use cases.
Thanks for looking for those.
It's worth noting now that template renders are wrapped in a rolled back transaction.
Yeah, that helps with mutators but not accessors. Having read access to everything isn't brilliant.
An alternative would be to add public result and resultset accessors specifically instead of enabling access to all private accessors. Would that be a better solution?
No I don't think so. Notice templates should be simple. We're overcomplicating them. I get so many complaints about the notice editor, but Template::Toolkit makes a WYSIWYG pretty much impossible: bug 11583 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 --- Comment #9 from David Cook <dcook@prosentient.com.au> --- (In reply to Kyle M Hall (khall) from comment #7)
A small handful of generic accessors would be better then a multitude of specific ones that we'd need to maintain without knowing if they are even being used. I'll try to find some specific use cases.
Except that we don't create specific things unless we know that people are using them. The base should be "nothing" and then we should be adding up. Not the base being everything and then trying to subtract down. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@openfifth.c | |o.uk --- Comment #10 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- I don't understand the need for this at all either I'm afraid.. it just feels like introducing a possible security risk to me without introducing any real benefit. We wrapped DBIC with Koha::Objects.. if we're going to go and unwrap them what was the point of adding the wrapper in the first place? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32453 --- Comment #11 from David Cook <dcook@prosentient.com.au> --- At the end of the day, I think it comes back to "what are you trying to do"? I doubt libraries are asking for the _result or _resultset objects. But I imagine they're asking for something? -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org