Bugzilla – Attachment 107825 Details for
Bug 26138
Errors if enable_plugins is zero
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26138: Make Koha::Plugins->call return consistent value
Bug-26138-Make-KohaPlugins-call-return-consistent-.patch (text/plain), 2.94 KB, created by
Alex Buckley
on 2020-08-05 10:29:03 UTC
(
hide
)
Description:
Bug 26138: Make Koha::Plugins->call return consistent value
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2020-08-05 10:29:03 UTC
Size:
2.94 KB
patch
obsolete
>From e7269ae062079fc6a0a316dfa6ea33b0b2312af7 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 5 Aug 2020 09:30:31 +0200 >Subject: [PATCH] Bug 26138: Make Koha::Plugins->call return consistent value > >It must return an empty array in case the enable_plugins config flag is >disabled > >Test plan: >Turn the config off in koha-conf >Start a search at the OPAC >Without this patch you got: > Can't use string ("0") as a HASH ref while "strict refs" in use at /home/vagrant/kohaclone/opac/opac-search.pl line 661 >With this patch applied you see the search result > >Followed test plan - works as described. > >Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz> >--- > Koha/Plugins.pm | 4 ++-- > t/db_dependent/Koha/Plugins/Plugins.t | 8 ++++++-- > 2 files changed, 8 insertions(+), 4 deletions(-) > >diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm >index 41974e54ac6..8d6957a2981 100644 >--- a/Koha/Plugins.pm >+++ b/Koha/Plugins.pm >@@ -63,9 +63,9 @@ Calls a plugin method for all enabled plugins > sub call { > my ($class, $method, @args) = @_; > >+ my @responses; > if (C4::Context->config('enable_plugins')) { > my @plugins = $class->new({ enable_plugins => 1 })->GetPlugins({ method => $method }); >- my @responses; > @plugins = grep { $_->can($method) } @plugins; > foreach my $plugin (@plugins) { > my $response = eval { $plugin->$method(@args) }; >@@ -77,8 +77,8 @@ sub call { > push @responses, $response; > } > >- return @responses; > } >+ return @responses; > } > > =head2 GetPlugins >diff --git a/t/db_dependent/Koha/Plugins/Plugins.t b/t/db_dependent/Koha/Plugins/Plugins.t >index 92b5c5c6b73..f49bd252fcc 100755 >--- a/t/db_dependent/Koha/Plugins/Plugins.t >+++ b/t/db_dependent/Koha/Plugins/Plugins.t >@@ -47,12 +47,13 @@ BEGIN { > my $schema = Koha::Database->new->schema; > > subtest 'call() tests' => sub { >- plan tests => 2; >+ plan tests => 3; > > $schema->storage->txn_begin; > # Temporarily remove any installed plugins data > Koha::Plugins::Methods->delete; > >+ t::lib::Mocks::mock_config('enable_plugins', 1); > my $plugins = Koha::Plugins->new({ enable_plugins => 1 }); > my @plugins = $plugins->InstallPlugins; > foreach my $plugin (@plugins) { >@@ -70,6 +71,10 @@ subtest 'call() tests' => sub { > $expected = [ { error => 0 } ]; > is_deeply(\@responses, $expected, 'call() should return all responses from plugins'); > >+ t::lib::Mocks::mock_config('enable_plugins', 0); >+ @responses = Koha::Plugins->call('check_password', { password => '1234' }); >+ is_deeply(\@responses, [], 'call() should return an empty array if plugins are disabled'); >+ > $schema->storage->txn_rollback; > }; > >@@ -352,5 +357,4 @@ subtest 'new() tests' => sub { > is( ref($result), 'Koha::Plugins', 'calling new with enable_plugins makes it override the config' ); > }; > >-$schema->storage->txn_rollback; > Koha::Plugins::Methods->delete; >-- >2.11.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 26138
:
107819
|
107825
|
107830