Bugzilla – Attachment 12512 Details for
Bug 8818
Authority linker error on Z cataloging
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 8818: make sure we load modules before using them
SIGNED-OFF-Bug-8818-make-sure-we-load-modules-befo.patch (text/plain), 2.70 KB, created by
Nicole C. Engard
on 2012-09-26 00:29:42 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 8818: make sure we load modules before using them
Filename:
MIME Type:
Creator:
Nicole C. Engard
Created:
2012-09-26 00:29:42 UTC
Size:
2.70 KB
patch
obsolete
>From 93816a5850b5aedd37011ff8fc05ebda59d1f048 Mon Sep 17 00:00:00 2001 >From: Jared Camins-Esakov <jcamins@cpbibliography.com> >Date: Tue, 25 Sep 2012 19:38:32 -0400 >Subject: [PATCH] [SIGNED-OFF] 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> >--- > C4/Biblio.pm | 11 +++++------ > misc/link_bibs_to_authorities.pl | 11 +++++------ > 2 files changed, 10 insertions(+), 12 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index ed8a169..231baf3 100644 >--- a/C4/Biblio.pm >+++ b/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( >diff --git a/misc/link_bibs_to_authorities.pl b/misc/link_bibs_to_authorities.pl >index b35a00e..37596c5 100755 >--- a/misc/link_bibs_to_authorities.pl >+++ b/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( >-- >1.7.2.3
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8818
:
12511
| 12512