Browse Source

Bug 8818: make sure we load modules before using them

An eval { eval "require $module;" }; was replaced with
eval { eval { require $module; }; }; which is a no-op, meaning that
the linker was not getting loaded, and the catalog module was throwing
up a big nasty error every time someone tried to save a record with a
heading. This patch replaces the require with can_load from
Module::Load::Conditional, which is PBP-friendly, and offers equivalent
functionality.

Signed-off-by: Nicole C. Engard <nengard@bywatersolutions.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
3.10.x
Jared Camins-Esakov 12 years ago
committed by Paul Poulain
parent
commit
813c744008
  1. 11
      C4/Biblio.pm
  2. 11
      misc/link_bibs_to_authorities.pl

11
C4/Biblio.pm

@ -28,6 +28,7 @@ use MARC::Record;
use MARC::File::USMARC;
use MARC::File::XML;
use POSIX qw(strftime);
use Module::Load::Conditional qw(can_load);
use C4::Koha;
use C4::Dates qw/format_date/;
@ -491,13 +492,11 @@ sub BiblioAutoLink {
my $linker_module =
"C4::Linker::" . ( C4::Context->preference("LinkerModule") || 'Default' );
eval { eval {require $linker_module}; };
if ($@) {
unless ( can_load( modules => { $linker_module => undef } ) ) {
$linker_module = 'C4::Linker::Default';
eval {require $linker_module};
}
if ($@) {
return 0, 0;
unless ( can_load( modules => { $linker_module => undef } ) ) {
return 0, 0;
}
}
my $linker = $linker_module->new(

11
misc/link_bibs_to_authorities.pl

@ -18,6 +18,7 @@ use Pod::Usage;
use Data::Dumper;
use Time::HiRes qw/time/;
use POSIX qw/strftime ceil/;
use Module::Load::Conditional qw(can_load);
sub usage {
pod2usage( -verbose => 2 );
@ -53,13 +54,11 @@ if ( not $result or $want_help ) {
my $linker_module =
"C4::Linker::" . ( C4::Context->preference("LinkerModule") || 'Default' );
eval { eval "require $linker_module"; };
if ($@) {
unless ( can_load( modules => { $linker_module => undef } ) ) {
$linker_module = 'C4::Linker::Default';
eval "require $linker_module";
}
if ($@) {
die "Unable to load linker module. Aborting.";
unless ( can_load( modules => { $linker_module => undef } ) ) {
die "Unable to load linker module. Aborting.";
}
}
my $linker = $linker_module->new(

Loading…
Cancel
Save