Bugzilla – Attachment 143445 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.13 KB, created by
Olivier Hubert
on 2022-11-08 16:07:56 UTC
(
hide
)
Description:
Bug 31074: Reload a plugin's module before installation
Filename:
MIME Type:
Creator:
Olivier Hubert
Created:
2022-11-08 16:07:56 UTC
Size:
2.13 KB
patch
obsolete
>From 1cd54ad35d212bbbdf3845843e056b8d38b27dd6 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 | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > >diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm >index a3c47006b5..8a09d9f9b3 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.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