Bugzilla – Attachment 24430 Details for
Bug 9579
Facets truncation broken for multi-byte characters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9579: Facets truncation broken for multi-byte characters
Bug-9579-Facets-truncation-broken-for-multi-byte-c.patch (text/plain), 2.27 KB, created by
Tomás Cohen Arazi (tcohen)
on 2014-01-16 00:13:28 UTC
(
hide
)
Description:
Bug 9579: Facets truncation broken for multi-byte characters
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2014-01-16 00:13:28 UTC
Size:
2.27 KB
patch
obsolete
>From c327d6601a85e23500901f3e5542c5caea1e44d8 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@gmail.com> >Date: Wed, 15 Jan 2014 21:06:04 -0300 >Subject: [PATCH] Bug 9579: Facets truncation broken for multi-byte characters > >We seem to be relying on whatever Zoom::Results->render return, and >Perl doesn't explicitly consider it UNICODE data. That's why CORE::substr >(and probably CORE::length too) cut the bytes wrong. > >This patch just decodes the UTF-8 data that render() returns and then >Perl behaves, heh. > >It uses Encode::decode_utf8 which is already a dependency for the current >stable Koha releases. > > To test: > - Set FacetLabelTruncationLength = 4 to make sure it will try to truncate > the facet label. > - Add a record with multiple multibyte characters in the author name > (copy and paste a cyrillic character several times so it is looong). > Note: make sure there are at least two records so you're presented the search results. > - Reindex zebra to make it possible to search the record. > - Search for the record. > - Notice the facet with cyrillic characters is broken in the place it gets truncated. > - Apply the patch and repeat the search. > - Notice the string is not broken. > - Sign off. > >Regards >To+ > >Sponsored-by: Universidad Nacional de Cordoba >--- > C4/Search.pm | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 18a0f5f..d09fe4c 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -36,6 +36,7 @@ use URI::Escape; > use Business::ISBN; > use MARC::Record; > use MARC::Field; >+use Encode qw/decode_utf8/; > use utf8; > use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG); > >@@ -503,8 +504,8 @@ sub getRecords { > $size > $facets_maxrecs ? $facets_maxrecs : $size; > for my $facet (@$facets) { > for ( my $j = 0 ; $j < $jmax ; $j++ ) { >- my $render_record = >- $results[ $i - 1 ]->record($j)->render(); >+ my $render_record = decode_utf8( >+ $results[ $i - 1 ]->record($j)->render()); > my @used_datas = (); > foreach my $tag ( @{ $facet->{tags} } ) { > >-- >1.8.3.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9579
:
15202
|
15259
|
16942
|
16953
|
24425
|
24426
|
24430
|
24684
|
24725
|
24959