Bugzilla – Attachment 144129 Details for
Bug 30358
Strip leading/trailing whitespace characters from input fields when cataloguing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30358 (follow-up): Do not strip whitespace from control fields
Bug-30358-follow-up-Do-not-strip-whitespace-from-c.patch (text/plain), 2.89 KB, created by
Aleisha Amohia
on 2022-11-21 21:40:51 UTC
(
hide
)
Description:
Bug 30358 (follow-up): Do not strip whitespace from control fields
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2022-11-21 21:40:51 UTC
Size:
2.89 KB
patch
obsolete
>From 9362b852bc91431aa6e2efd8452403aa1f4fb805 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Mon, 21 Nov 2022 21:34:32 +0000 >Subject: [PATCH] Bug 30358 (follow-up): Do not strip whitespace from control > fields > >--- > Koha/MetadataRecord.pm | 16 +++++++++------- > t/db_dependent/Biblio/ModBiblioMarc.t | 6 +++++- > 2 files changed, 14 insertions(+), 8 deletions(-) > >diff --git a/Koha/MetadataRecord.pm b/Koha/MetadataRecord.pm >index 80e8ecdd48b..a1a54c2613d 100644 >--- a/Koha/MetadataRecord.pm >+++ b/Koha/MetadataRecord.pm >@@ -120,13 +120,15 @@ sub stripWhitespaceChars { > my ( $record ) = @_; > > foreach my $field ( $record->fields ) { >- foreach my $subfield ( $field->subfields ) { >- my $key = $subfield->[0]; >- my $value = $subfield->[1]; >- $value =~ s/[\n\r]+/ /g; >- $value =~ s/^\s+|\s+$|^\t+|\t+$//g; >- $field->add_subfields( $key => $value ); # add subfield to the end of the subfield list >- $field->delete_subfield( pos => 0 ); # delete the subfield at the top of the subfield list >+ unless ( $field->is_control_field ) { >+ foreach my $subfield ( $field->subfields ) { >+ my $key = $subfield->[0]; >+ my $value = $subfield->[1]; >+ $value =~ s/[\n\r]+/ /g; >+ $value =~ s/^\s+|\s+$|^\t+|\t+$//g; >+ $field->add_subfields( $key => $value ); # add subfield to the end of the subfield list >+ $field->delete_subfield( pos => 0 ); # delete the subfield at the top of the subfield list >+ } > } > } > >diff --git a/t/db_dependent/Biblio/ModBiblioMarc.t b/t/db_dependent/Biblio/ModBiblioMarc.t >index e049598da94..fc38684c39b 100755 >--- a/t/db_dependent/Biblio/ModBiblioMarc.t >+++ b/t/db_dependent/Biblio/ModBiblioMarc.t >@@ -48,7 +48,7 @@ subtest "Check MARC field length calculation" => sub { > }; > > subtest "StripWhitespaceChars tests" => sub { >- plan tests => 3; >+ plan tests => 4; > > t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); > t::lib::Mocks::mock_preference('StripWhitespaceChars', 0); >@@ -56,6 +56,7 @@ subtest "StripWhitespaceChars tests" => sub { > my $biblio = t::lib::TestBuilder->new->build_sample_biblio; > my $record = MARC::Record->new; > $record->append_fields( >+ MARC::Field->new( '003', "abcdefg\n" ), > MARC::Field->new( '245', '', '', a => " My\ntitle\n" ), > ); > >@@ -75,6 +76,9 @@ subtest "StripWhitespaceChars tests" => sub { > my $amendedrec = $biblio->metadata->record; > my $amendedtitle = $amendedrec->title; > is( $amendedtitle, "My title", "Whitespace characters removed from title because StripWhitespaceChars is enabled" ); >+ >+ my $f003 = $record->field('003')->data; >+ is( $f003, "abcdefg\n", "Whitespace characters are not stripped from control fields" ); > }; > > $schema->storage->txn_rollback; >-- >2.20.1
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 30358
:
132202
|
132275
|
132919
|
133055
|
133056
|
133140
|
133224
|
133225
|
134195
|
134453
|
137451
|
137452
|
137453
|
137454
|
137455
|
137456
|
137457
|
139110
|
142905
|
142906
|
142907
|
142908
|
142909
|
142910
|
142911
|
142912
|
143053
|
143057
|
143058
|
143059
|
143060
|
143061
|
143062
|
143063
|
143064
|
143065
|
144120
|
144121
|
144122
|
144123
|
144124
|
144125
|
144126
|
144127
|
144128
|
144129
|
144130
|
144171
|
145308
|
145309
|
145310
|
145311
|
145312
|
145313
|
145314
|
145315
|
145316
|
145317
|
145318
|
151202
|
151203
|
151204
|
151205
|
151206
|
151207
|
151208
|
151210
|
151212
|
151214
|
151215