Bugzilla – Attachment 191892 Details for
Bug 41684
notices_content hook is not checking if individual plugins are enabled and is reloading plugins
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41684: Make `notices_content` hook be used with `get_enabled_plugins()`
c9c1199.patch (text/plain), 2.42 KB, created by
David Nind
on 2026-01-23 04:38:44 UTC
(
hide
)
Description:
Bug 41684: Make `notices_content` hook be used with `get_enabled_plugins()`
Filename:
MIME Type:
Creator:
David Nind
Created:
2026-01-23 04:38:44 UTC
Size:
2.42 KB
patch
obsolete
>From c9c1199fbc269209823068fe544bb167e1b1e061 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= <tomascohen@theke.io> >Date: Thu, 22 Jan 2026 16:16:42 -0300 >Subject: [PATCH] Bug 41684: Make `notices_content` hook be used with > `get_enabled_plugins()` >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch makes the plugin hook load plugins using `get_enabled_plugins()`. This has >the immediate effect of using the already cached plugin objects without reinstantiating them. > >This way transactions don't get broken for schema reloads. Also, only enabled plugins >are loaded/attempted to be loaded. > >To test: >1. Run: > $ ktd --shell > k$ prove t/db_dependent/Koha/Plugins/Notices_content_hook.t >=> SUCCESS: Tests pass >2. Apply this patch >3. Repeat 1 >=> SUCCESS: Tests still pass: fundamental behavior remains unchanged. >4. Sign off :-D > >Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Letters.pm | 29 ++++++++++++----------------- > 1 file changed, 12 insertions(+), 17 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 26d866d7f0..6f171d3802 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -620,24 +620,19 @@ sub GetPreparedLetter { > } > > # add plugin-generated objects >- if ( C4::Context->config("enable_plugins") ) { >- my @plugins = Koha::Plugins->new->GetPlugins( >- { >- method => 'notices_content', >- } >- ); >+ my @plugins = Koha::Plugins->get_enabled_plugins(); >+ @plugins = grep { $_->can('notices_content') } @plugins; > >- foreach my $plugin (@plugins) { >- my $namespace = $plugin->get_metadata()->{namespace}; >- if ($namespace) { >- try { >- if ( my $content = $plugin->notices_content( \%params ) ) { >- $objects->{plugin_content}->{$namespace} = $content; >- } >- } catch { >- next; >- }; >- } >+ foreach my $plugin (@plugins) { >+ my $namespace = $plugin->get_metadata()->{namespace}; >+ if ($namespace) { >+ try { >+ if ( my $content = $plugin->notices_content( \%params ) ) { >+ $objects->{plugin_content}->{$namespace} = $content; >+ } >+ } catch { >+ next; >+ }; > } > } > >-- >2.39.5 >
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 41684
:
191885
| 191892