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

(-)a/C4/Biblio.pm (-4 / +2 lines)
Lines 262-268 Returns 1 on success 0 on failure Link Here
262
=cut
262
=cut
263
263
264
sub ModBiblio {
264
sub ModBiblio {
265
    my ( $record, $biblionumber, $frameworkcode ) = @_;
265
    my ( $record, $biblionumber, $frameworkcode, $called_by_linker ) = @_;
266
    if (!$record) {
266
    if (!$record) {
267
        carp 'No record passed to ModBiblio';
267
        carp 'No record passed to ModBiblio';
268
        return 0;
268
        return 0;
Lines 273-279 sub ModBiblio { Link Here
273
        logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio BEFORE=>" . $newrecord->as_formatted );
273
        logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio BEFORE=>" . $newrecord->as_formatted );
274
    }
274
    }
275
275
276
    if (C4::Context->preference('BiblioAddsAuthorities')) {
276
    if (C4::Context->preference('BiblioAddsAuthorities') && !$called_by_linker) {
277
        BiblioAutoLink( $record, $frameworkcode );
277
        BiblioAutoLink( $record, $frameworkcode );
278
    }
278
    }
279
279
Lines 622-633 safest place. Link Here
622
622
623
sub _check_valid_auth_link {
623
sub _check_valid_auth_link {
624
    my ( $authid, $field ) = @_;
624
    my ( $authid, $field ) = @_;
625
626
    require C4::AuthoritiesMarc;
625
    require C4::AuthoritiesMarc;
627
626
628
    my $authorized_heading =
627
    my $authorized_heading =
629
      C4::AuthoritiesMarc::GetAuthorizedHeading( { 'authid' => $authid } ) || '';
628
      C4::AuthoritiesMarc::GetAuthorizedHeading( { 'authid' => $authid } ) || '';
630
631
   return ($field->as_string('abcdefghijklmnopqrstuvwxyz') eq $authorized_heading);
629
   return ($field->as_string('abcdefghijklmnopqrstuvwxyz') eq $authorized_heading);
632
}
630
}
633
631
(-)a/t/db_dependent/Biblio.t (-2 / +18 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 11;
20
use Test::More tests => 12;
21
use Test::MockModule;
21
use Test::MockModule;
22
use List::MoreUtils qw( uniq );
22
use List::MoreUtils qw( uniq );
23
use MARC::Record;
23
use MARC::Record;
Lines 495-500 subtest 'MarcFieldForCreatorAndModifier' => sub { Link Here
495
    is($record->subfield('998', 'd'), 'Jane Doe', '998$d = Jane Doe');
495
    is($record->subfield('998', 'd'), 'Jane Doe', '998$d = Jane Doe');
496
};
496
};
497
497
498
subtest 'ModBiblio called from linker test' => sub {
499
    plan tests => 2;
500
    my $called = 0;
501
    t::lib::Mocks::mock_preference('BiblioAddsAuthorities', 1);
502
    my $biblio_mod = Test::MockModule->new( 'C4::Biblio' );
503
    $biblio_mod->mock( 'LinkBibHeadingsToAuthorities', sub {
504
        $called = 1;
505
    });
506
    my $record = MARC::Record->new();
507
    my ($biblionumber) = C4::Biblio::AddBiblio($record,'');
508
    C4::Biblio::ModBiblio($record,$biblionumber,'');
509
    is($called,1,"We called to link bibs because not from linker");
510
    $called = 0;
511
    C4::Biblio::ModBiblio($record,$biblionumber,'',1);
512
    is($called,0,"We didn't call to link bibs because from linker");
513
};
514
498
# Cleanup
515
# Cleanup
499
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
516
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
500
$schema->storage->txn_rollback;
517
$schema->storage->txn_rollback;
501
- 

Return to bug 21957