Bug 38142: (follow-up) Choose language to report from authority to bibliographic record

- Rename LanguageToReportOnMerge system preference to LanguageToUseOnMerge
 - Use "use" instead of "report" in system preference description
 - Mark this feature as UNIMARC-only.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Matthias Meusburger 2025-05-20 09:53:52 +00:00 committed by Katrin Fischer
parent 0c027e9db1
commit f51ec30438
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
4 changed files with 16 additions and 14 deletions

View File

@ -1620,10 +1620,10 @@ sub merge {
my @record_to;
my $short_langcode = C4::Context->preference('LanguageToReportOnMerge');
my $short_langcode = C4::Context->preference('LanguageToUseOnMerge');
if ( $auth_tag_to_report_to && $MARCto && $MARCto->field($auth_tag_to_report_to) ) {
my $chosen_field = $MARCto->field($auth_tag_to_report_to);
if ($short_langcode) {
if ( uc( C4::Context->preference('marcflavour') ) eq 'UNIMARC' && $short_langcode ) {
foreach my $field ( $MARCto->field($auth_tag_to_report_to) ) {
my $subfield = $field->subfield('7');
if (

View File

@ -10,10 +10,10 @@ return {
$dbh->do(
q{
INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES
('LanguageToReportOnMerge','','','If set, the authority field having the given language code in its $7 subfield will be reported to the bibliographic record if it exists, rather than the first field. The code can be in a short, 2 characters long form (example: ba for latin) or in a long, 8 characters long form, with the short form in position 5 and 6 starting from 1 (example: ba0yba0y for latin). A list of available codes can be found here: https://documentation.abes.fr/sudoc/formats/unmb/DonneesCodees/CodesZone104.htm#$d','Free');
('LanguageToUseOnMerge','','','If set, the authority field having the given language code in its $7 subfield will be used in the bibliographic record if it exists, rather than the first field. The code can be in a short, 2 characters long form (example: ba for latin) or in a long, 8 characters long form, with the short form in position 5 and 6 starting from 1 (example: ba0yba0y for latin). A list of available codes can be found here: https://documentation.abes.fr/sudoc/formats/unmb/DonneesCodees/CodesZone104.htm#$d. Please note that this feature is available only for UNIMARC.','Free');
}
);
say_success( $out, "Added new system preference 'LanguageToReportOnMerge'" );
say_success( $out, "Added new system preference 'LanguageToUseOnMerge'" );
}
};

View File

@ -104,8 +104,8 @@ Authorities:
- consider the intended use of MARC21 authority records (008/14-16) during cataloging and linking.
- "<br/>NOTE: If you enable this preference, 'No attempt to code' in 008/14-16 is excluded from search results too."
-
- "If set, the authority field having the given language code in its $7 subfield will be reported to the bibliographic record if it exists, rather than the first field. The code can be in a short, 2 characters long form (example: ba for latin) or in a long, 8 characters long form, with the short form in position 5 and 6 starting from 1 (example: ba0yba0y for latin). A list of available codes can be found here: https://documentation.abes.fr/sudoc/formats/unmb/DonneesCodees/CodesZone104.htm#$d"
- pref: LanguageToReportOnMerge
- "If set, the authority field having the given language code in its $7 subfield will be used in the bibliographic record if it exists, rather than the first field. The code can be in a short, 2 characters long form (example: ba for latin) or in a long, 8 characters long form, with the short form in position 5 and 6 starting from 1 (example: ba0yba0y for latin). A list of available codes can be found here: https://documentation.abes.fr/sudoc/formats/unmb/DonneesCodees/CodesZone104.htm#$d. Please note that this feature is available only for UNIMARC."
- pref: LanguageToUseOnMerge
Linker:
-
- Use the

View File

@ -213,7 +213,8 @@ subtest 'Test merge A1 to modified A1, test strict mode' => sub {
subtest 'Test merge A1 to B1 (choosing language)' => sub {
plan tests => 4;
t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', '' );
t::lib::Mocks::mock_preference( 'marcflavour', 'UNIMARC' );
t::lib::Mocks::mock_preference( 'LanguageToUseOnMerge', '' );
my $auth1 = MARC::Record->new;
$auth1->append_fields(
@ -236,27 +237,27 @@ subtest 'Test merge A1 to B1 (choosing language)' => sub {
is(
$biblio->subfield( '609', 'a' ), 'language da',
'When LanguageToReportOnMerge is not set, the first authority field is used'
'When LanguageToUseOnMerge is not set, the first authority field is used'
);
t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', 'ba' );
t::lib::Mocks::mock_preference( 'LanguageToUseOnMerge', 'ba' );
C4::AuthoritiesMarc::merge( { mergefrom => $authid1, MARCfrom => $auth1, mergeto => $authid1, MARCto => $auth1 } );
$biblio = Koha::Biblios->find($biblionumber)->metadata->record;
is(
$biblio->subfield( '609', 'a' ), 'language ba',
'When LanguageToReportOnMerge is set, the field with the matching language is reported'
'When LanguageToUseOnMerge is set, the field with the matching language is used'
);
t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', 'xx' );
t::lib::Mocks::mock_preference( 'LanguageToUseOnMerge', 'xx' );
C4::AuthoritiesMarc::merge( { mergefrom => $authid1, MARCfrom => $auth1, mergeto => $authid1, MARCto => $auth1 } );
$biblio = Koha::Biblios->find($biblionumber)->metadata->record;
is(
$biblio->subfield( '609', 'a' ), 'language da',
'When LanguageToReportOnMerge is set to a value that does not exist in the authority, the first authority field is used'
'When LanguageToUseOnMerge is set to a value that does not exist in the authority, the first authority field is used'
);
# Long form of lang code
t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', 'ba' );
t::lib::Mocks::mock_preference( 'LanguageToUseOnMerge', 'ba' );
my $auth2 = MARC::Record->new;
$auth2->append_fields(
MARC::Field->new( '109', '0', '0', 'a' => 'language da (long form)', '7' => 'ba0yda0y' ),
@ -277,9 +278,10 @@ subtest 'Test merge A1 to B1 (choosing language)' => sub {
my $biblio2 = Koha::Biblios->find($biblionumber2)->metadata->record;
is(
$biblio2->subfield( '609', 'a' ), 'language ba (long form)',
'When LanguageToReportOnMerge is set, the field with the matching language in its long form is reported'
'When LanguageToUseOnMerge is set, the field with the matching language in its long form is used'
);
t::lib::Mocks::mock_preference( 'marcflavour', $marcflavour ) if $marcflavour;
};
subtest 'Test merge A1 to B1 (changing authtype)' => sub {