Bugzilla – Attachment 143989 Details for
Bug 24606
Allow storing item values as a template for creating new items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24606: (QA follow-up) Fix encoding/decoding
Bug-24606-QA-follow-up-Fix-encodingdecoding.patch (text/plain), 1.43 KB, created by
Marcel de Rooy
on 2022-11-17 10:17:09 UTC
(
hide
)
Description:
Bug 24606: (QA follow-up) Fix encoding/decoding
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-11-17 10:17:09 UTC
Size:
1.43 KB
patch
obsolete
>From 8cb2a0b9547e738fdfad8716780610a035b6198a Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 17 Nov 2022 10:02:08 +0000 >Subject: [PATCH] Bug 24606: (QA follow-up) Fix encoding/decoding >Content-Type: text/plain; charset=utf-8 > >We should use OO interface and leave encoding to database >layer. > >Test plan: >Add a new item template containing real Unicode chars. >Save. Apply on new item. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Item/Template.pm | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > >diff --git a/Koha/Item/Template.pm b/Koha/Item/Template.pm >index d6d0555a9e..8adf9ea125 100644 >--- a/Koha/Item/Template.pm >+++ b/Koha/Item/Template.pm >@@ -41,7 +41,7 @@ sub store { > my ($self) = @_; > > if ( ref( $self->contents ) eq 'HASH' ) { >- $self->contents( encode_json( $self->contents ) ); >+ $self->contents( $self->_json->encode( $self->contents ) ); > } > > $self = $self->SUPER::store; >@@ -56,11 +56,20 @@ Returns a deserilized perl structure of the JSON formatted contents > sub decoded_contents { > my ($self) = @_; > >- return decode_json( encode_utf8($self->contents) ) if $self->contents; >+ return $self->_json->decode($self->contents) if $self->contents; > } > > =head2 Internal methods > >+=head3 _json >+ >+=cut >+ >+sub _json { >+ my $self = shift; >+ $self->{_json} //= JSON->new; # Keep utf8 off ! >+} >+ > =head3 _type > > =cut >-- >2.30.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 24606
:
141613
|
141614
|
141615
|
141616
|
141617
|
141717
|
141718
|
141719
|
141720
|
141721
|
141972
|
142003
|
142004
|
142005
|
142006
|
142007
|
142008
|
142833
|
142834
|
142835
|
142836
|
142837
|
142877
|
142878
|
142879
|
142880
|
142881
|
142882
|
142883
|
142884
|
142885
|
142886
|
142887
|
142888
|
143020
|
143569
|
143570
|
143571
|
143572
|
143573
|
143574
|
143575
|
143576
|
143577
|
143578
|
143579
|
143580
|
143581
|
143794
|
143795
|
143796
| 143989 |
143990
|
144161