View | Details | Raw Unified | Return to bug 38142
Collapse All | Expand All

(-)a/C4/AuthoritiesMarc.pm (-2 / +2 lines)
Lines 1620-1629 sub merge { Link Here
1620
1620
1621
    my @record_to;
1621
    my @record_to;
1622
1622
1623
    my $short_langcode = C4::Context->preference('LanguageToReportOnMerge');
1623
    my $short_langcode = C4::Context->preference('LanguageToUseOnMerge');
1624
    if ( $auth_tag_to_report_to && $MARCto && $MARCto->field($auth_tag_to_report_to) ) {
1624
    if ( $auth_tag_to_report_to && $MARCto && $MARCto->field($auth_tag_to_report_to) ) {
1625
        my $chosen_field = $MARCto->field($auth_tag_to_report_to);
1625
        my $chosen_field = $MARCto->field($auth_tag_to_report_to);
1626
        if ($short_langcode) {
1626
        if ( uc( C4::Context->preference('marcflavour') ) eq 'UNIMARC' && $short_langcode ) {
1627
            foreach my $field ( $MARCto->field($auth_tag_to_report_to) ) {
1627
            foreach my $field ( $MARCto->field($auth_tag_to_report_to) ) {
1628
                my $subfield = $field->subfield('7');
1628
                my $subfield = $field->subfield('7');
1629
                if (
1629
                if (
(-)a/installer/data/mysql/atomicupdate/Bug38142.pl (-3 / +3 lines)
Lines 2-18 use Modern::Perl; Link Here
2
2
3
return {
3
return {
4
    bug_number  => "38142",
4
    bug_number  => "38142",
5
    description => "LanguageToReportOnMerge",
5
    description => "LanguageToUseOnMerge",
6
    up          => sub {
6
    up          => sub {
7
        my ($args) = @_;
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
        $dbh->do(
9
        $dbh->do(
10
            q{
10
            q{
11
            INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES
11
            INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES
12
           ('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');
12
           ('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');
13
        }
13
        }
14
        );
14
        );
15
15
16
        say $out "Added new syspref 'LanguageToReportOnMerge'";
16
        say_success( $out, "Added new syspref 'LanguageToUseOnMerge'" );
17
    }
17
    }
18
};
18
};
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref (-2 / +2 lines)
Lines 104-111 Authorities: Link Here
104
            - consider the intended use of MARC21 authority records (008/14-16) during cataloging and linking.
104
            - consider the intended use of MARC21 authority records (008/14-16) during cataloging and linking.
105
            - "<br/>NOTE: If you enable this preference, 'No attempt to code' in 008/14-16 is excluded from search results too."
105
            - "<br/>NOTE: If you enable this preference, 'No attempt to code' in 008/14-16 is excluded from search results too."
106
        -
106
        -
107
            - "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"
107
            - "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."
108
            - pref: LanguageToReportOnMerge
108
            - pref: LanguageToUseOnMerge
109
    Linker:
109
    Linker:
110
        -
110
        -
111
            - Use the
111
            - Use the
(-)a/t/db_dependent/Authority/Merge.t (-9 / +10 lines)
Lines 213-219 subtest 'Test merge A1 to modified A1, test strict mode' => sub { Link Here
213
subtest 'Test merge A1 to B1 (choosing language)' => sub {
213
subtest 'Test merge A1 to B1 (choosing language)' => sub {
214
    plan tests => 4;
214
    plan tests => 4;
215
215
216
    t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', '' );
216
    t::lib::Mocks::mock_preference( 'marcflavour',          'UNIMARC' );
217
    t::lib::Mocks::mock_preference( 'LanguageToUseOnMerge', '' );
217
218
218
    my $auth1 = MARC::Record->new;
219
    my $auth1 = MARC::Record->new;
219
    $auth1->append_fields(
220
    $auth1->append_fields(
Lines 236-262 subtest 'Test merge A1 to B1 (choosing language)' => sub { Link Here
236
237
237
    is(
238
    is(
238
        $biblio->subfield( '609', 'a' ), 'language da',
239
        $biblio->subfield( '609', 'a' ), 'language da',
239
        'When LanguageToReportOnMerge is not set, the first authority field is used'
240
        'When LanguageToUseOnMerge is not set, the first authority field is used'
240
    );
241
    );
241
242
242
    t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', 'ba' );
243
    t::lib::Mocks::mock_preference( 'LanguageToUseOnMerge', 'ba' );
243
    C4::AuthoritiesMarc::merge( { mergefrom => $authid1, MARCfrom => $auth1, mergeto => $authid1, MARCto => $auth1 } );
244
    C4::AuthoritiesMarc::merge( { mergefrom => $authid1, MARCfrom => $auth1, mergeto => $authid1, MARCto => $auth1 } );
244
    $biblio = Koha::Biblios->find($biblionumber)->metadata->record;
245
    $biblio = Koha::Biblios->find($biblionumber)->metadata->record;
245
    is(
246
    is(
246
        $biblio->subfield( '609', 'a' ), 'language ba',
247
        $biblio->subfield( '609', 'a' ), 'language ba',
247
        'When LanguageToReportOnMerge is set, the field with the matching language is reported'
248
        'When LanguageToUseOnMerge is set, the field with the matching language is used'
248
    );
249
    );
249
250
250
    t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', 'xx' );
251
    t::lib::Mocks::mock_preference( 'LanguageToUseOnMerge', 'xx' );
251
    C4::AuthoritiesMarc::merge( { mergefrom => $authid1, MARCfrom => $auth1, mergeto => $authid1, MARCto => $auth1 } );
252
    C4::AuthoritiesMarc::merge( { mergefrom => $authid1, MARCfrom => $auth1, mergeto => $authid1, MARCto => $auth1 } );
252
    $biblio = Koha::Biblios->find($biblionumber)->metadata->record;
253
    $biblio = Koha::Biblios->find($biblionumber)->metadata->record;
253
    is(
254
    is(
254
        $biblio->subfield( '609', 'a' ), 'language da',
255
        $biblio->subfield( '609', 'a' ), 'language da',
255
        'When LanguageToReportOnMerge is set to a value that does not exist in the authority, the first authority field is used'
256
        'When LanguageToUseOnMerge is set to a value that does not exist in the authority, the first authority field is used'
256
    );
257
    );
257
258
258
    # Long form of lang code
259
    # Long form of lang code
259
    t::lib::Mocks::mock_preference( 'LanguageToReportOnMerge', 'ba' );
260
    t::lib::Mocks::mock_preference( 'LanguageToUseOnMerge', 'ba' );
260
    my $auth2 = MARC::Record->new;
261
    my $auth2 = MARC::Record->new;
261
    $auth2->append_fields(
262
    $auth2->append_fields(
262
        MARC::Field->new( '109', '0', '0', 'a' => 'language da (long form)', '7' => 'ba0yda0y' ),
263
        MARC::Field->new( '109', '0', '0', 'a' => 'language da (long form)', '7' => 'ba0yda0y' ),
Lines 277-285 subtest 'Test merge A1 to B1 (choosing language)' => sub { Link Here
277
    my $biblio2 = Koha::Biblios->find($biblionumber2)->metadata->record;
278
    my $biblio2 = Koha::Biblios->find($biblionumber2)->metadata->record;
278
    is(
279
    is(
279
        $biblio2->subfield( '609', 'a' ), 'language ba (long form)',
280
        $biblio2->subfield( '609', 'a' ), 'language ba (long form)',
280
        'When LanguageToReportOnMerge is set, the field with the matching language in its long form is reported'
281
        'When LanguageToUseOnMerge is set, the field with the matching language in its long form is used'
281
    );
282
    );
282
283
284
    t::lib::Mocks::mock_preference( 'marcflavour', $marcflavour ) if $marcflavour;
283
};
285
};
284
286
285
subtest 'Test merge A1 to B1 (changing authtype)' => sub {
287
subtest 'Test merge A1 to B1 (changing authtype)' => sub {
286
- 

Return to bug 38142