Bug 15182: Conditionally load Koha::NorwegianPatronDB
authorDavid Cook <dcook@prosentient.com.au>
Tue, 17 Nov 2015 01:36:16 +0000 (12:36 +1100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 17 Nov 2015 12:48:05 +0000 (09:48 -0300)
This patch loads Koha::NorwegianPatronDB if it can, or adds a warning
to the log if it can't load it.

Since the Koha::NorwegianPatronDB functionality in C4::Members is
wrapped in system preferences, the loading of the module is
irrelevant unless one actually wants to use the module and its
associated functionality.

NOTE:

This patch fixes a problem where we were getting errors saying
Crypt::GCrypt couldn't be loaded even though it's not a required
dependency.

This patch will likely only affect people not using Debian-based
systems where libcrypt-gcrypt-perl is available. The current
version of Crypt::GCrypt doesn't build so it's not an option
for most non-Debian users to install this not required
dependency in order to work around this issue...

Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>
Works as advertised for Debian-based systems

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

C4/Members.pm

index 2616598..19a7cfc 100644 (file)
@@ -40,7 +40,11 @@ use Koha::Borrower::Debarments qw(IsDebarred);
 use Text::Unaccent qw( unac_string );
 use Koha::AuthUtils qw(hash_password);
 use Koha::Database;
-require Koha::NorwegianPatronDB;
+
+use Module::Load::Conditional qw( can_load );
+if ( ! can_load( modules => { 'Koha::NorwegianPatronDB' => undef } ) ) {
+   warn "Unable to load Koha::NorwegianPatronDB";
+}
 
 our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug);