From: Jason Stephenson <jason@sigio.com> Date: Sun, 7 Jul 2019 11:18:01 +0000 (-0400) Subject: Lp 1835620: Require some Storage submodules instead of use them X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ca6a08dbe196a7c2e989acc8a4c542ad6be1e5fd;p=evergreen%2Fjoelewis.git Lp 1835620: Require some Storage submodules instead of use them 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> --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI.pm index d164251ad6..ac5779494d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI.pm @@ -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); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg.pm index 3a645953a4..6105d7ae50 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg.pm @@ -10,10 +10,15 @@ # 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 $@; diff --git a/Open-ILS/src/perlmods/t/09-OpenILS-Application-Storage-Driver.t b/Open-ILS/src/perlmods/t/09-OpenILS-Application-Storage-Driver.t index 9e93ade705..4ccba01bf9 100644 --- a/Open-ILS/src/perlmods/t/09-OpenILS-Application-Storage-Driver.t +++ b/Open-ILS/src/perlmods/t/09-OpenILS-Application-Storage-Driver.t @@ -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' );