Bugzilla – Attachment 142517 Details for
Bug 31074
Cached plugin code is used in Koha even after changes to plugin (install/upgrade/uninstall)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31074: Reload a plugin's module before installation
Bug-31074-Reload-a-plugins-module-before-installat.patch (text/plain), 2.18 KB, created by
Olivier Hubert
on 2022-10-24 14:52:34 UTC
(
hide
)
Description:
Bug 31074: Reload a plugin's module before installation
Filename:
MIME Type:
Creator:
Olivier Hubert
Created:
2022-10-24 14:52:34 UTC
Size:
2.18 KB
patch
obsolete
>From c20e806352fb290b0c07db86eddb539e9e948573 Mon Sep 17 00:00:00 2001 >From: Olivier Hubert <olivier.hubert@inlibro.com> >Date: Mon, 24 Oct 2022 10:44:42 -0400 >Subject: [PATCH] Bug 31074: Reload a plugin's module before installation > >When using Plack, memcached or another caching mechanism, a plugin's old version is retained >in the cache, even when uninstalled. If the plugin is then reinstalled, the old version is >used, no matter the version installed. To prevent this, the plugin's module is reloaded every >time it is installed. > >To test: >1) Install a plugin, like the kitchen sink. > https://github.com/bywatersolutions/dev-koha-plugin-kitchen-sink/releases >2) Modify the .kpz and in KitchenSink.pm, change MINIMUN_VERSION. >3) Uninstall the plugin. >4) Install the new version. >5) The Minimum Koha version column still lists the old version. >6) Apply patch. >7) Repeat steps 1 through 4. >8) Observe that the Minimum Koha version column lists the correct version. >9) Sign off. >--- > Koha/Plugins.pm | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > >diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm >index f7b716638d..59a83b3c0e 100644 >--- a/Koha/Plugins.pm >+++ b/Koha/Plugins.pm >@@ -33,6 +33,8 @@ use C4::Output; > use Koha::Exceptions::Plugin; > use Koha::Plugins::Methods; > >+use Module::Refresh; >+ > BEGIN { > my $pluginsdir = C4::Context->config("pluginsdir"); > my @pluginsdir = ref($pluginsdir) eq 'ARRAY' ? @$pluginsdir : $pluginsdir; >@@ -187,11 +189,22 @@ sub InstallPlugins { > > my @plugin_classes = $self->plugins(); > my @plugins; >+ my $refresher = Module::Refresh->new; > > foreach my $plugin_class (@plugin_classes) { > if ( can_load( modules => { $plugin_class => undef }, nocache => 1 ) ) { > next unless $plugin_class->isa('Koha::Plugins::Base'); > >+ # If using Plack or memcached and reinstalling a Plugin that existed previously, the module needs to be refreshed. >+ my $module_name = ($plugin_class =~ s|::|/|gr) . '.pm'; >+ >+ try { >+ $refresher->refresh_module($module_name); >+ } >+ catch { >+ warn "$_"; >+ } >+ > my $plugin; > my $failed_instantiation; > >-- >2.34.1
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 31074
:
142517
|
143445
|
143668
|
143730
|
152463