Bugzilla – Attachment 143730 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
David Nind
on 2022-11-10 21:25:08 UTC
(
hide
)
Description:
Bug 31074: Reload a plugin's module before installation
Filename:
MIME Type:
Creator:
David Nind
Created:
2022-11-10 21:25:08 UTC
Size:
2.18 KB
patch
obsolete
>From 33a4deab4823b6c278bba5472dc66ca674ac2b87 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. > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Plugins.pm | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > >diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm >index a3c47006b5..08eb6995e6 100644 >--- a/Koha/Plugins.pm >+++ b/Koha/Plugins.pm >@@ -33,6 +33,7 @@ use C4::Output; > use Koha::Cache::Memory::Lite; > use Koha::Exceptions::Plugin; > use Koha::Plugins::Methods; >+use Module::Refresh; > > use constant ENABLED_PLUGINS_CACHE_KEY => 'enabled_plugins'; > >@@ -231,11 +232,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.30.2
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