Bugzilla – Attachment 192338 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()`
2dea127.patch (text/plain), 3.16 KB, created by
Martin Renvoize (ashimema)
on 2026-02-02 18:03:47 UTC
(
hide
)
Description:
Bug 41684: Make `notices_content` hook be used with `get_enabled_plugins()`
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2026-02-02 18:03:47 UTC
Size:
3.16 KB
patch
obsolete
>From 2dea127eb851e76d4280061799866fb8f4115bcb 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> >Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >--- > C4/Letters.pm | 35 +++++++++++++++-------------------- > 1 file changed, 15 insertions(+), 20 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 26d866d7f04..1db40371776 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -214,8 +214,8 @@ sub GetLettersAvailableForALibrary { > } > > return [ >- map { $letters{$_} } >- sort { $letters{$a}->{name} cmp $letters{$b}->{name} } >+ map { $letters{$_} } >+ sort { $letters{$a}->{name} cmp $letters{$b}->{name} } > keys %letters > ]; > >@@ -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; >+ }; > } > } > >@@ -1211,7 +1206,7 @@ sub GetQueuedMessages { > my $params = shift; > > my $dbh = C4::Context->dbh(); >- my $statement = << 'ENDSQL'; >+ my $statement = <<'ENDSQL'; > SELECT message_id, borrowernumber, subject, content, message_transport_type, status, time_queued, updated_on, failure_code, from_address, to_address, cc_address > FROM message_queue > ENDSQL >-- >2.52.0 >
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
| 192338