Lp 1835620: Require some Storage submodules instead of use them
authorJason Stephenson <jason@sigio.com>
Sun, 7 Jul 2019 11:18:01 +0000 (07:18 -0400)
committerJason Boyer <jboyer@equinoxinitiative.org>
Wed, 23 Oct 2019 14:31:57 +0000 (10:31 -0400)
Switch from "use" to "require" for submodules in OpenILS::Application
::Storage::CDBI and OpenILS::Application::Storage::Driver::Pg.
Circular dependencies and other issues cause the following errors at
compile time for those modules:

Compilation failed in require at
/usr/local/share/perl/5.28.1/OpenILS/Application/Storage/CDBI.pm line
9.

Compilation failed in require at
/usr/local/share/perl/5.26.1/OpenILS/Application/Storage/Driver/Pg.pm
line 15.

Require loads the submodules at run time and does not attempt to
import any methods.  This is the behavior we want, eliminates the
above errors, and everything still works.

Add comments above the required modules explaining why require is
needed and not use.

Enable and reorder all of the tests in Open-ILS/src/perlmods/t/
09-OpenILS-Application-Storage-Driver.t.  Repairing the above issue
also repairs these tests.

Signed-off-by: Jason Stephenson <jason@sigio.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Jason Boyer <jboyer@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg.pm
Open-ILS/src/perlmods/t/09-OpenILS-Application-Storage-Driver.t

index d164251..ac57794 100644 (file)
@@ -6,18 +6,22 @@ BEGIN {
 use base qw/Class::DBI/;
 use Class::DBI::AbstractSearch;
 
-use OpenILS::Application::Storage::CDBI::actor;
-use OpenILS::Application::Storage::CDBI::action;
-use OpenILS::Application::Storage::CDBI::booking;
-use OpenILS::Application::Storage::CDBI::asset;
-use OpenILS::Application::Storage::CDBI::serial;
-use OpenILS::Application::Storage::CDBI::authority;
-use OpenILS::Application::Storage::CDBI::biblio;
-use OpenILS::Application::Storage::CDBI::config;
-use OpenILS::Application::Storage::CDBI::metabib;
-use OpenILS::Application::Storage::CDBI::money;
-use OpenILS::Application::Storage::CDBI::permission;
-use OpenILS::Application::Storage::CDBI::container;
+# The following modules add, or use, subroutines in modules that are
+# not available when this module is compiled.  We therefore "require"
+# these modules rather than "use" them.  Everything is available at
+# run time.
+require OpenILS::Application::Storage::CDBI::actor;
+require OpenILS::Application::Storage::CDBI::action;
+require OpenILS::Application::Storage::CDBI::booking;
+require OpenILS::Application::Storage::CDBI::asset;
+require OpenILS::Application::Storage::CDBI::serial;
+require OpenILS::Application::Storage::CDBI::authority;
+require OpenILS::Application::Storage::CDBI::biblio;
+require OpenILS::Application::Storage::CDBI::config;
+require OpenILS::Application::Storage::CDBI::metabib;
+require OpenILS::Application::Storage::CDBI::money;
+require OpenILS::Application::Storage::CDBI::permission;
+require OpenILS::Application::Storage::CDBI::container;
 
 use OpenSRF::Utils::JSON;
 use OpenSRF::Utils::Logger qw(:level);
index 3a64595..6105d7a 100644 (file)
   # OpenILS::Application::Storage.
   #-------------------------------------------------------------------------------
     package OpenILS::Application::Storage::Driver::Pg;
-    use OpenILS::Application::Storage::Driver::Pg::cdbi;
-    use OpenILS::Application::Storage::Driver::Pg::fts;
-    use OpenILS::Application::Storage::Driver::Pg::storage;
-    use OpenILS::Application::Storage::Driver::Pg::dbi;
+    # The following modules add, or use, subroutines in modules that
+    # are not available when this module is compiled.  We therefore
+    # "require" these modules rather than "use" them.  Everything is
+    # available at run time.
+    require OpenILS::Application::Storage::Driver::Pg::cdbi;
+    require OpenILS::Application::Storage::Driver::Pg::fts;
+    require OpenILS::Application::Storage::Driver::Pg::storage;
+    require OpenILS::Application::Storage::Driver::Pg::dbi;
+
     use UNIVERSAL::require; 
     BEGIN {                 
         'Class::DBI::Frozen::301'->use or 'Class::DBI'->use or die $@;
index 9e93ade..4ccba01 100644 (file)
@@ -1,12 +1,10 @@
 #!perl -T
 
-use Test::More tests => 3;
+use Test::More tests => 6;
 
+use_ok( 'OpenILS::Application::Storage::Driver::Pg' );
 use_ok( 'OpenILS::Application::Storage::Driver::Pg::cdbi' );
 use_ok( 'OpenILS::Application::Storage::Driver::Pg::fts' );
+use_ok( 'OpenILS::Application::Storage::Driver::Pg::storage' );
+use_ok( 'OpenILS::Application::Storage::Driver::Pg::dbi' );
 use_ok( 'OpenILS::Application::Storage::Driver::Pg::QueryParser' );
-
-# These modules are not meant to be loaded as a normal Perl module
-# use_ok( 'OpenILS::Application::Storage::Driver::Pg' );
-# use_ok( 'OpenILS::Application::Storage::Driver::Pg::dbi' );
-# use_ok( 'OpenILS::Application::Storage::Driver::Pg::storage' );