From 5d30296e1d87dec3b54d58f1dda3a06f2133e217 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 6 Aug 2020 11:05:55 -0400 Subject: [PATCH] Bug 26163: Add plugin directories to PERL5LIB It would be nice if we could create Koha objects and schema files to be used in plugins. The problem is that by the time the Plugin directories are added to @INC only at the point that Koha::Plugins is evaluated. This is too late for loading additional Schema files that may be part of a plugin. In addition, it makes sense to allow plugins to have a 'lib' directory so that any additional object and schema files can be stored inside the plugin assets directory and not pollute the root plugins directory. Without such a 'lib' directory, we would need to place them in the plugins directory such as '/var/lib/koha/instancename/plugins/Koha/MyObject.pm'. This file would not be removed when the plugin is uninstalled. Test Plan: 1) Apply this patch 2) Start koha-testing-docker or Update your plack.psgi file with the changes from the patch ( e.g. /etc/koha/sites/kohadevbox/plack.psgi ) 3) Install the Kitchen Sink plugin, version 2.1.42 https://github.com/bywatersolutions/koha-plugin-kitchen-sink/releases/download/v2.1.42/koha-plugin-kitchen-sink-v2.1.42.kpz 4) Restart all the things! 5) Note the message "Kitchen Sink test module was loaded!" in the plack error log when you visit the plugin's pages ( confi, tool, report ) --- debian/scripts/koha-plack | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/debian/scripts/koha-plack b/debian/scripts/koha-plack index 90da6cbd36..b9a7ad54a2 100755 --- a/debian/scripts/koha-plack +++ b/debian/scripts/koha-plack @@ -393,6 +393,14 @@ if [ $# -gt 0 ]; then export DEV_INSTALL export KOHA_HOME PERL5LIB=$PERL5LIB:$KOHA_HOME/installer:$KOHA_HOME/lib/installer + + for dir in $(xmlstarlet sel -t -v 'yazgfs/config/pluginsdir' "/etc/koha/sites/${name}/koha-conf.xml"); do + PERL5LIB=$PERL5LIB:$dir + for lib in $(find $dir -name 'lib'); do + PERL5LIB=$PERL5LIB:$lib + done; + done; + # If debug mode is enabled, add the debugger lib path # to PERL5LIB if appropriate if [ "$debug_mode" = "yes" ]; then -- 2.24.1 (Apple Git-126)