@@ -, +, @@ the additional frameworks, the mapping in Default. framework and clear the mapping via mysql command line: UPDATE marc_subfield_structure SET kohafield=NULL WHERE frameworkcode=[your_framework] AND tagfield='100' AND tagsubfield='a'; biblio.author again in that framework. mappings for biblioitems.pages: 300a and say 300g. Toggle with some field values in those fields in the cataloging editor and verify the contents of biblio.copyrightdate and biblioitems.pages. The former should contain one year (due to additional logic) and the latter should contain A | B if both fields are filled. Remove the mapping for 300g. add or receive an order as usual. for coded_location_qualifier). This is very unusual but serves well in testing multiple mappings for items. Add or receive an order (fill 952f and 952o) with same and/or different values. Verify the contents of items.callnumber. (Check with regular item editor; see note.) Do a similar edit in the regular item editor. Note: You should expect to see A | B in both 952f and 925o if both fields are filled with a different value. Set items.coded_location_qualifier back to 952f in koha2marclinks. Note: When AcqCreateItem==ordering, you will not see A|B in the callno field when adding an item on neworderempty.pl. But when you submit the main form, addorder.pl is called. At that time an item is created and you will see that A|B is in both fields (952f and 952o). --- installer/data/mysql/atomicupdate/bug19096.perl | 94 +++++++++++++++++++++++++ t/db_dependent/Koha/MarcSubfieldStructures.t | 1 - 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug19096.perl --- a/installer/data/mysql/atomicupdate/bug19096.perl +++ a/installer/data/mysql/atomicupdate/bug19096.perl @@ -0,0 +1,94 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + my $dbh = C4::Context->dbh; + + my $msss = $dbh->selectall_arrayref(q| + SELECT kohafield, tagfield, tagsubfield, frameworkcode + FROM marc_subfield_structure + WHERE frameworkcode != '' + |, { Slice => {} }); + + + my $sth = $dbh->prepare(q| + SELECT kohafield + FROM marc_subfield_structure + WHERE frameworkcode = '' + AND tagfield = ? + AND tagsubfield = ? + |); + + my @exceptions; + for my $mss ( @$msss ) { + $sth->execute($mss->{tagfield}, $mss->{tagsubfield} ); + my ( $default_kohafield ) = $sth->fetchrow_array(); + if( $mss->{kohafield} ) { + push @exceptions, { frameworkcode => $mss->{frameworkcode}, tagfield => $mss->{tagfield}, tagsubfield => $mss->{tagsubfield}, kohafield => $mss->{kohafield} } if not $default_kohafield or $default_kohafield ne $mss->{kohafield}; + } else { + push @exceptions, { frameworkcode => $mss->{frameworkcode}, tagfield => $mss->{tagfield}, tagsubfield => $mss->{tagsubfield}, kohafield => q{} } if $default_kohafield; + } + } + + if (@exceptions) { + print +"WARNING: The Default framework is now considered as authoritative for Koha to MARC mappings. We have found that your additional frameworks contained " + . scalar(@exceptions) + . " mapping(s) that deviate from the standard mappings. Please look at the following list and consider if you need to add them again in Default (possibly as a second mapping).\n"; + for my $exception (@exceptions) { + print "Field " + . $exception->{tagfield} . '$' + . $exception->{tagsubfield} + . " in framework " + . $exception->{frameworkcode} . ': '; + if ( $exception->{kohafield} ) { + print "Mapping to " + . $exception->{kohafield} + . " has been adjusted.\n"; + } + else { + print "Mapping has been reset.\n"; + } + } + + # Sync kohafield + + # Clear the destination frameworks first + $dbh->do(q| + UPDATE marc_subfield_structure + SET kohafield = NULL + WHERE frameworkcode > '' + AND Kohafield > '' + |); + + # Now copy from Default + my $msss = $dbh->selectall_arrayref(q| + SELECT kohafield, tagfield, tagsubfield + FROM marc_subfield_structure + WHERE frameworkcode = '' + AND kohafield > '' + |, { Slice => {} }); + my $sth = $dbh->prepare(q| + UPDATE marc_subfield_structure + SET kohafield = ? + WHERE frameworkcode > '' + AND tagfield = ? + AND tagsubfield = ? + |); + for my $mss (@$msss) { + $sth->execute( $mss->{kohafield}, $mss->{tagfield}, + $mss->{tagsubfield} ); + } + + # Clear the cache + my @frameworkcodes = $dbh->selectall_arrayref(q| + SELECT frameworkcode FROM biblio_framework WHERE frameworkcode > '' + |); + for my $frameworkcode (@frameworkcodes) { + Koha::Caches->get_instance->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); + } + Koha::Caches->get_instance->clear_from_cache("default_value_for_mod_marc-"); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 19096 - Make Default authoritative for Koha to MARC mappings)\n"; +} --- a/t/db_dependent/Koha/MarcSubfieldStructures.t +++ a/t/db_dependent/Koha/MarcSubfieldStructures.t @@ -21,7 +21,6 @@ use Modern::Perl; use Test::More tests => 1; -use Koha::MarcSubfieldStructure; use Koha::MarcSubfieldStructures; use Koha::Database; --