2e0e15485e
Intermittently problems in the calling environment cause a C4::Biblio routine to be called with an undefined MARC::Record object. This results in the process dying and returning to the end user a low level message such as 'cannot call method x on an undefined object'. For exported subroutines taking a MARC::Record object, check that object is defined otherwise return a logical return value and log a stack trace to the error log. A couple of cases were checking but dying, this may have unwelcome results in a persistent environment so croak has been downgraded to carp Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Adds lots of checks for $record in various places, should not affect behaviour. Passed all tests and QA script, including new unit tests. Tested adding and saving a new record. Also tested detail and result pages without XSLT. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
82 lines
2.2 KiB
Perl
Executable file
82 lines
2.2 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
#
|
|
use strict;
|
|
use warnings;
|
|
|
|
use Test::More tests => 22;
|
|
|
|
BEGIN {
|
|
use_ok('C4::Biblio');
|
|
}
|
|
|
|
# test returns if undef record passed
|
|
# carp messages appear on stdout
|
|
|
|
my @arr = AddBiblio(undef, q{});
|
|
my $elements = @arr;
|
|
|
|
is($elements, 0, 'Add Biblio returns empty array for undef record');
|
|
|
|
my $ret = ModBiblio(undef, 0, '');
|
|
|
|
is( $ret, 0, 'ModBiblio returns zero if not passed rec');
|
|
|
|
$ret = BiblioAutoLink(undef, q{});
|
|
|
|
is( $ret, 0, 'BiblioAutoLink returns zero if not passed rec');
|
|
|
|
$ret = GetRecordValue('100', undef, q{});
|
|
ok( !defined $ret, 'GetRecordValue returns undef if not passed rec');
|
|
|
|
@arr = LinkBibHeadingsToAuthorities(q{}, q{});
|
|
is($arr[0], 0, 'LinkBibHeadingsToAuthorities correct error return');
|
|
|
|
$ret = GetCOinSBiblio();
|
|
ok( !defined $ret, 'GetCOinSBiblio returns undef if not passed rec');
|
|
|
|
$ret = GetMarcPrice(undef, 'MARC21');
|
|
ok( !defined $ret, 'GetMarcPrice returns undef if not passed rec');
|
|
|
|
$ret = GetMarcQuantity(undef, 'MARC21');
|
|
ok( !defined $ret, 'GetMarcQuantity returns undef if not passed rec');
|
|
|
|
$ret = GetMarcControlnumber();
|
|
ok( !defined $ret, 'GetMarcControlnumber returns undef if not passed rec');
|
|
|
|
$ret = GetMarcISBN();
|
|
ok( !defined $ret, 'GetMarcISBN returns undef if not passed rec');
|
|
|
|
$ret = GetMarcISSN();
|
|
ok( !defined $ret, 'GetMarcISSN returns undef if not passed rec');
|
|
|
|
$ret = GetMarcNotes();
|
|
ok( !defined $ret, 'GetMarcNotes returns undef if not passed rec');
|
|
|
|
$ret = GetMarcSubjects();
|
|
ok( !defined $ret, 'GetMarcSubjects returns undef if not passed rec');
|
|
|
|
$ret = GetMarcAuthors();
|
|
ok( !defined $ret, 'GetMarcAuthors returns undef if not passed rec');
|
|
|
|
$ret = GetMarcUrls();
|
|
ok( !defined $ret, 'GetMarcUrls returns undef if not passed rec');
|
|
|
|
$ret = GetMarcSeries();
|
|
ok( !defined $ret, 'GetMarcSeries returns undef if not passed rec');
|
|
|
|
$ret = GetMarcHosts();
|
|
ok( !defined $ret, 'GetMarcHosts returns undef if not passed rec');
|
|
|
|
my $hash_ref = TransformMarcToKoha(undef, undef);
|
|
|
|
isa_ok( $hash_ref, 'HASH');
|
|
|
|
$elements = keys %{$hash_ref};
|
|
|
|
is($elements, 0, 'Empty hashref returned for undefined record in TransformMarcToKoha');
|
|
|
|
$ret = ModBiblioMarc();
|
|
ok( !defined $ret, 'ModBiblioMarc returns undef if not passed rec');
|
|
|
|
$ret = RemoveAllNsb();
|
|
ok( !defined $ret, 'RemoveAllNsb returns undef if not passed rec');
|