Bugzilla – Attachment 130159 Details for
Bug 28584
Remove hyphens from EAN when adding a new record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28584: Remove hyphens from EAN when adding new record
Bug-28584-Remove-hyphens-from-EAN-when-adding-new-.patch (text/plain), 3.31 KB, created by
Kyle M Hall (khall)
on 2022-02-04 11:16:31 UTC
(
hide
)
Description:
Bug 28584: Remove hyphens from EAN when adding new record
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2022-02-04 11:16:31 UTC
Size:
3.31 KB
patch
obsolete
>From 0d385f21745638d4c245311bb168058abcdab86e Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Mon, 24 May 2021 13:19:06 +0300 >Subject: [PATCH] Bug 28584: Remove hyphens from EAN when adding new record >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Add functionality to TransformMarcToKoha so that hyphens >are removed from biblioitem tables "ean" column but EAN >value in MARC record is not touched. > >To test: > >1. Apply patch. >2. Create new record with EAN field(s) having hyphen(s) e.g. 74628-8972 >3. Check records MARC details >=> EAN has hyphen >4. Check record from biblioitem table in database >=> EAN doesn't have hyphen(s) > >Prove t/db_dependent/Biblio/TransfornMarcToKoha.t > >Sponsored-by: Koha-Suomi Oy > >Signed-off-by: Emmanuel Bétemps <e.betemps@gmail.com> >--- > C4/Biblio.pm | 4 ++++ > t/db_dependent/Biblio/TransformMarcToKoha.t | 8 +++++--- > 2 files changed, 9 insertions(+), 3 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index ce2b949554..a1769e96ab 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -2383,6 +2383,10 @@ sub TransformMarcToKohaOneField { > $retval = _adjust_pubyear( $retval ); > } > >+ if( $kohafield =~ /ean/ ) { >+ $retval =~ s/-//g; >+ } >+ > return $retval; > } > >diff --git a/t/db_dependent/Biblio/TransformMarcToKoha.t b/t/db_dependent/Biblio/TransformMarcToKoha.t >index 9cd675858b..7240081667 100755 >--- a/t/db_dependent/Biblio/TransformMarcToKoha.t >+++ b/t/db_dependent/Biblio/TransformMarcToKoha.t >@@ -42,20 +42,22 @@ Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '500', tagsu > Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); > > subtest 'Test a few mappings' => sub { >- plan tests => 7; >+ plan tests => 8; > > my $marc = MARC::Record->new; > $marc->append_fields( > MARC::Field->new( '300', '', '', a => 'a1', b => 'b1' ), > MARC::Field->new( '300', '', '', a => 'a2', b => 'b2' ), > MARC::Field->new( '500', '', '', a => 'note1', a => 'note2' ), >+ MARC::Field->new( '024', '', '', a => '9678-56789', a => '8657-6547-89' ), > ); > my $result = C4::Biblio::TransformMarcToKoha( $marc ); > # Note: TransformMarcToKoha stripped the table prefix biblio. >- is( keys %{$result}, 3, 'Found all three mappings' ); >+ is( keys %{$result}, 4, 'Found all four mappings' ); > is( $result->{field1}, 'a1 | a2', 'Check field1 results' ); > is( $result->{field2}, 'b1 | b2', 'Check field2 results' ); > is( $result->{field3}, 'note1 | note2', 'Check field3 results' ); >+ is( $result->{ean}, '967856789 | 8657654789', 'Hyphens are removed from EAN field(s)' ); > > is( C4::Biblio::TransformMarcToKohaOneField( 'biblio.field1', $marc ), > $result->{field1}, 'TransformMarcToKohaOneField returns biblio.field1'); >@@ -67,7 +69,7 @@ subtest 'Test a few mappings' => sub { > # CAUTION: This parameter of TransformMarcToKoha will be removed later > my $new_fw = t::lib::TestBuilder->new->build({source => 'BiblioFramework'}); > $result = C4::Biblio::TransformMarcToKoha($marc, $new_fw->{frameworkcode}); >- is( keys %{$result}, 3, 'Still found all three mappings' ); >+ is( keys %{$result}, 4, 'Still found all four mappings' ); > }; > > subtest 'Multiple mappings for one kohafield' => sub { >-- >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 28584
:
122059
|
130159
|
130670