[Bug 11302] New: Template::output should deal with object
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 Bug ID: 11302 Summary: Template::output should deal with object Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: critical Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: gmcharlt@gmail.com Reporter: jonathan.druart@biblibre.com QA Contact: testopia@bugs.koha-community.org This report replaces bug 6554. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dubyk@library.lviv.ua --- Comment #1 from Jonathan Druart <jonathan.druart@biblibre.com> --- *** Bug 6554 has been marked as a duplicate of this bug. *** -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 --- Comment #2 from Jonathan Druart <jonathan.druart@biblibre.com> --- Created attachment 23154 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=23154&action=edit Bug 11302: Template::output should deal with objects if a ref is not HASH or ARRAY, C4::Template::output assumes it is a scalar. Which is wrong, it could be an object. At least the member 'description' of the C4::Category object should be encoded. Test plan: Before applying the patch - translate a template for a language - create a patron category with a no-ASCII character - got the patron home page and select the translated language - you should see a broken encoding Apply the patch - refresh the page - all looks good now -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|gmcharlt@gmail.com |jonathan.druart@biblibre.co | |m -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |http://bugs.koha-community. | |org/bugzilla3/show_bug.cgi? | |id=11290 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 Josef Moravec <josef.moravec@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |josef.moravec@gmail.com -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 M. de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |m.de.rooy@rijksmuseum.nl -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 Jacek Ablewicz <abl@biblos.pk.edu.pl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |abl@biblos.pk.edu.pl -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 Petter Goksøyr Åsen <boutrosboutrosboutros@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |boutrosboutrosboutros@gmail | |.com --- Comment #3 from Petter Goksøyr Åsen <boutrosboutrosboutros@gmail.com> --- When I apply this patch, I get failure on the plugins page: http://localhost:8080/cgi-bin/koha/plugins/plugins-home.pl Software error: Not a HASH reference at /home/boutros/Projects/deichman/kohaclone/C4/Templates.pm line 158. Note that I have installed a plugin with non-ascii characters, so that might be why -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 --- Comment #4 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- First observation: If I put a diacritical char in the branchname, the staff home page will show a mangled char in the upper-right corner (directly after login). If you refresh after login or come back there, it will disappear. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 M. de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA --- Comment #5 from M. de Rooy <m.de.rooy@rijksmuseum.nl> --- Some (!) additional observations: Facets in staff search show mangled chars. Patron category (with latin diacritic and chinese char) on memberentry.pl mangled. Branch name mangled too on memberentry.pl Catalogue detail: mangled chars all over the place. Failed QA -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |RESOLVED Resolution|--- |INVALID --- Comment #6 from Jonathan Druart <jonathan.druart@biblibre.com> --- I was just a try. If it does not work, I reopen the initial report and close this one. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 Jacek Ablewicz <abl@biblos.pk.edu.pl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID |--- -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 Jacek Ablewicz <ablewicz@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #23154|0 |1 is obsolete| | --- Comment #7 from Jacek Ablewicz <ablewicz@gmail.com> --- Created attachment 26151 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=26151&action=edit Bug 11302: Template::output should deal with objects If a ref is not HASH or ARRAY, C4::Template::output assumes it is a scalar. Which is wrong, it could be an object. Note: this is yet another / alternative take on the problem, with only bare minimum changes made to the code base, so this (counter-)patch - while not pretty - hopefully should be less regression-prone. Right now, the only white-listed object this patch deals with is 'Koha::AdditionalField' introduced by bug 10855. In case it tests OK, without any regressions, we can add another objects (C4::Category etc.) later on. Test plan: 1) apply bug 10855 first; observe that non-ascii characters (in authorized category names or additional field labels) are not properly handled, 2) apply patch, 3) ensure that encoding of non-ascii characters for features added by 10855 got fixed, 4) there should be no character-encoding-related regressions of any kind appearing anywhere in the system. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 Jacek Ablewicz <abl@biblos.pk.edu.pl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |Needs Signoff Patch complexity|--- |Trivial patch See Also| |http://bugs.koha-community. | |org/bugzilla3/show_bug.cgi? | |id=10855 -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 Dobrica Pavlinusic <dpavlin@rot13.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dpavlin@rot13.org --- Comment #8 from Dobrica Pavlinusic <dpavlin@rot13.org> --- Sorry Jacek your simpler approach doesn't work for authorized values with UTF-8 characters in them (in fact, it doesn't even return double encoded utf-8, it just doesn't return anything which is somewhat puzzling since I can't figure out from code why it does so). -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 --- Comment #9 from Jacek Ablewicz <abl@biblos.pk.edu.pl> --- (In reply to Dobrica Pavlinusic from comment #8)
Sorry Jacek your simpler approach doesn't work for authorized values with UTF-8 characters in them (in fact, it doesn't even return double encoded utf-8, it just doesn't return anything which is somewhat puzzling since I can't figure out from code why it does so).
It took me a while to reproduce this issue, but indeed there seems to be at least one serious problem with this particular approach, which is affecting bug 10855 in non intuitive way (I'm not entirely sure it's the same problem you've encountered - it can be yet another/new one as well). Anyway, it boils down to this: - unpatched C4/Template.pm does not encode hash keys, and does not deal with objects at all - patched C4/Template.pm does deal with whitelisted objects, but it only encodes scalar values within them (in the same exact manner as unpatched version deals with ordinary, unblessed hashes) - if there are utf8 characters in additional field names, some code fragments introduced by 10855 - e.g. this one, used repeatedly in subscription-add.tt additional_fields.${field.name} wouldn't work any longer. While field.name (being a scalar value) gets encoded by patched C4/Template.pm, keys in additional_fields hash do not. What's worse, I don't see any easy solution for this problem (other than making some - pretty substantial - changes to 10855). We can patch Template.pm somehow further, so it will encode hash keys - but that's rather risky move IMO; who knows how many regressions we may get elsewhere in the system.. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 Jacek Ablewicz <abl@biblos.pk.edu.pl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |In Discussion -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 --- Comment #10 from Dobrica Pavlinusic <dpavlin@rot13.org> --- I suspect that touching encoding in C4::Template::output is wrong direction to take. I would rather decode utf-8 as soon as it arrives in Koha and have correct encoding within perl code and then let TT deal with encoding it back to binary bytes by using binmode( STDOUT, ":utf8" ); instead of traversing all hashes we are passing to TT which has performance impact. I will extend http://wiki.koha-community.org/wiki/Handling_UTF8_in_development to include more information about it and prepare initial patch with replaces usage of utf8::(en|de)code witn Encode::(en|de)code so we can see if this approach is feasible. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 --- Comment #11 from Jacek Ablewicz <abl@biblos.pk.edu.pl> --- (In reply to Dobrica Pavlinusic from comment #10)
I will extend http://wiki.koha-community.org/wiki/Handling_UTF8_in_development to include more information about it and prepare initial patch with replaces usage of utf8::(en|de)code witn Encode::(en|de)code so we can see if this approach is feasible.
It would be really great to get rid of all those numerous ::[en|de]code, html_entity and so on.. Sounds like a pretty ambitious task, though. If I understand correctly, essentially it would be something like bug 6554 revival (which was expected for 3.14 but unfortunately got reverted), only better this time. Hopefully it will finally be included in 3.16 ;) -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11302 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|In Discussion |RESOLVED See Also| |http://bugs.koha-community. | |org/bugzilla3/show_bug.cgi? | |id=11944 Resolution|--- |INVALID --- Comment #12 from Jonathan Druart <jonathan.druart@biblibre.com> --- This patch does not fix correctly the issue. See bug 11944 for the next step. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org