Bugzilla – Attachment 48674 Details for
Bug 5404
C4::Koha::subfield_is_koha_internal_p no longer serves a purpose
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 5404: Move the test to a new IsMarcStructureInternal sub
Bug-5404-Move-the-test-to-a-new-IsMarcStructureInt.patch (text/plain), 5.76 KB, created by
Marcel de Rooy
on 2016-03-04 11:00:37 UTC
(
hide
)
Description:
Bug 5404: Move the test to a new IsMarcStructureInternal sub
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-03-04 11:00:37 UTC
Size:
5.76 KB
patch
obsolete
>From d8cffce1f44d4233e82c33d849d5c39852847d63 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 29 Feb 2016 10:04:51 +0000 >Subject: [PATCH] Bug 5404: Move the test to a new IsMarcStructureInternal sub >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Acquisition.pm | 2 +- > C4/Biblio.pm | 22 ++++++++++++++++++++++ > C4/Items.pm | 2 +- > cataloguing/additem.pl | 2 +- > t/db_dependent/Biblio.t | 22 +++++++++++++++++++++- > tools/batchMod.pl | 2 +- > 6 files changed, 47 insertions(+), 5 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index 5dc9cb3..d878201 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -2996,7 +2996,7 @@ sub FillWithDefaultValues { > next unless $tag; > next if $tag == $itemfield; > for my $subfield ( sort keys %{ $tagslib->{$tag} } ) { >- next unless ref $tagslib->{$tag}{$subfield}; # Not a valid subfield (mandatory, tab, lib) >+ next if IsMarcStructureInternal($tagslib->{$tag}{$subfield}); > my $defaultvalue = $tagslib->{$tag}{$subfield}{defaultvalue}; > if ( defined $defaultvalue and $defaultvalue ne '' ) { > my @fields = $record->field($tag); >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index a2b1d0a..2926a80 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -92,6 +92,7 @@ BEGIN { > > &GetAuthorisedValueDesc > &GetMarcStructure >+ &IsMarcStructureInternal > &GetMarcFromKohaField > &GetMarcSubfieldStructureFromKohaField > &GetFrameworkCode >@@ -1081,6 +1082,27 @@ sub GetBiblioItemInfosOf { > > =head1 FUNCTIONS FOR HANDLING MARC MANAGEMENT > >+=head2 IsMarcStructureInternal >+ >+ my $tagslib = C4::Biblio::GetMarcStructure(); >+ for my $tag ( sort keys %$tagslib ) { >+ next unless $tag; >+ for my $subfield ( sort keys %{ $tagslib->{$tag} } ) { >+ next if IsMarcStructureInternal($tagslib->{$tag}{$subfield}); >+ } >+ # Process subfield >+ } >+ >+GetMarcStructure creates keys (lib, tab, mandatory, repeatable) for a display purpose. >+These different values should not be processed as valid subfields. >+ >+=cut >+ >+sub IsMarcStructureInternal { >+ my ( $subfield ) = @_; >+ return ref $subfield ? 0 : 1; >+} >+ > =head2 GetMarcStructure > > $res = GetMarcStructure($forlibrarian,$frameworkcode); >diff --git a/C4/Items.pm b/C4/Items.pm >index d23fb7f..9594c98 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -2943,7 +2943,7 @@ sub PrepareItemrecordDisplay { > # loop through each subfield > my $cntsubf; > foreach my $subfield ( sort keys %{ $tagslib->{$tag} } ) { >- next unless ref $tagslib->{$tag}{$subfield}; # Not a valid subfield (mandatory, tab, lib) >+ next if IsMarcStructureInternal($tagslib->{$tag}{$subfield}); > next if ( $tagslib->{$tag}->{$subfield}->{'tab'} ne "10" ); > my %subfield_data; > $subfield_data{tag} = $tag; >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index 7a4031d..b9672c2 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -890,7 +890,7 @@ $itemrecord = $cookieitemrecord if ($prefillitem and not $justaddeditem and $op > # We generate form, and fill with values if defined > foreach my $tag ( keys %{$tagslib}){ > foreach my $subtag (keys %{$tagslib->{$tag}}){ >- next unless ref $tagslib->{$tag}{$subtag}; # Not a valid subfield (mandatory, tab, lib) >+ next if IsMarcStructureInternal($tagslib->{$tag}{$subtag}); > next if ($tagslib->{$tag}->{$subtag}->{'tab'} ne "10"); > next if any { /^$tag$subtag$/ } @fields; > >diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t >index 1023798..e23dc34 100755 >--- a/t/db_dependent/Biblio.t >+++ b/t/db_dependent/Biblio.t >@@ -17,9 +17,10 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 6; > use Test::MockModule; > >+use List::MoreUtils qw( uniq ); > use MARC::Record; > use t::lib::Mocks qw( mock_preference ); > >@@ -323,4 +324,23 @@ subtest 'GetMarcSubfieldStructureFromKohaField' => sub { > is($marc_subfield_structure, undef, "invalid kohafield returns undef"); > }; > >+subtest 'IsMarcStructureInternal' => sub { >+ plan tests => 6; >+ my $tagslib = GetMarcStructure(); >+ my @internals; >+ for my $tag ( sort keys %$tagslib ) { >+ next unless $tag; >+ for my $subfield ( sort keys %{ $tagslib->{$tag} } ) { >+ push @internals, $subfield if IsMarcStructureInternal($tagslib->{$tag}{$subfield}); >+ } >+ } >+ @internals = uniq @internals; >+ is( scalar(@internals), 4, ''); >+ is( grep( /^lib$/, @internals ), 1, '' ); >+ is( grep( /^tab$/, @internals ), 1, '' ); >+ is( grep( /^mandatory$/, @internals ), 1, '' ); >+ is( grep( /^repeatable$/, @internals ), 1, '' ); >+ is( grep( /^a$/, @internals ), 0, '' ); >+}; >+ > 1; >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index d62ef6d..5b104b6 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -308,7 +308,7 @@ my @subfieldsToAllow = split(/ /, $subfieldsToAllowForBatchmod); > foreach my $tag (sort keys %{$tagslib}) { > # loop through each subfield > foreach my $subfield (sort keys %{$tagslib->{$tag}}) { >- next unless ref $tagslib->{$tag}{$subfield}; # Not a valid subfield (mandatory, tab, lib) >+ next if IsMarcStructureInternal( $tagslib->{$tag}{$subfield} ); > next if (not $allowAllSubfields and $restrictededition && !grep { $tag . '$' . $subfield eq $_ } @subfieldsToAllow ); > next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10"); > # barcode and stocknumber are not meant to be batch-modified >-- >1.7.10.4
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 5404
:
47968
|
48099
|
48436
|
48450
|
48478
|
48673
| 48674 |
48675