Bug 22053 - Ability to disable some plugins
Summary: Ability to disable some plugins
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: System Administration (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Alex Arnaud
QA Contact: Tomás Cohen Arazi
URL:
Keywords:
: 21558 (view as bug list)
Depends on:
Blocks: 21073 22906 23168
  Show dependency treegraph
 
Reported: 2018-12-28 16:29 UTC by Alex Arnaud
Modified: 2019-06-20 11:51 UTC (History)
9 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Who signed the patch off:
Text to go in the release notes:
The ability to enable/disable plugins is added. This is particularly handy when testing new plugins or when plugins are not (yet) fully configured for production use.
Version(s) released in:
19.05.00


Attachments
Bug 22053: create unit tests (2.24 KB, patch)
2018-12-28 16:53 UTC, Alex Arnaud
Details | Diff | Splinter Review
Bug 22053: ability to enable/disable some plugins (7.66 KB, patch)
2018-12-28 16:53 UTC, Alex Arnaud
Details | Diff | Splinter Review
Bug 22053: update database (1.13 KB, patch)
2018-12-28 16:53 UTC, Alex Arnaud
Details | Diff | Splinter Review
[DO NOT PUSH] Bug 22053: provide staff-global.css (91.07 KB, patch)
2018-12-28 16:54 UTC, Alex Arnaud
Details | Diff | Splinter Review
Bug 10676: Fix behaviour of OpacHiddenItems for items.restricted (5.37 KB, text/plain)
2019-01-04 21:55 UTC, Pierre-Marc Thibault
Details
Bug 10676: Add unit tests - GetItemsInfo (2.79 KB, text/plain)
2019-01-04 21:55 UTC, Pierre-Marc Thibault
Details
Bug 22053: create unit tests (2.32 KB, patch)
2019-03-25 09:02 UTC, Alex Arnaud
Details | Diff | Splinter Review
Bug 22053: ability to enable/disable some plugins (7.72 KB, patch)
2019-03-25 09:02 UTC, Alex Arnaud
Details | Diff | Splinter Review
Bug 22053: update database (1.19 KB, patch)
2019-03-25 09:02 UTC, Alex Arnaud
Details | Diff | Splinter Review
[DO NOT PUSH] Bug 22053: provide staff-global.css (95.61 KB, patch)
2019-03-25 09:03 UTC, Alex Arnaud
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 22053: create unit tests (2.39 KB, patch)
2019-04-25 14:32 UTC, Claire Gravely
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 22053: ability to enable/disable some plugins (7.79 KB, patch)
2019-04-25 14:32 UTC, Claire Gravely
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 22053: update database (1.26 KB, patch)
2019-04-25 14:33 UTC, Claire Gravely
Details | Diff | Splinter Review
Bug 22053: create unit tests (2.44 KB, patch)
2019-04-25 22:34 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 22053: ability to enable/disable some plugins (7.87 KB, patch)
2019-04-25 22:34 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 22053: update database (1.31 KB, patch)
2019-04-25 22:34 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 22053: create unit tests (2.49 KB, patch)
2019-04-29 18:30 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 22053: ability to enable/disable some plugins (7.88 KB, patch)
2019-04-29 18:30 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 22053: update database (1.36 KB, patch)
2019-04-29 18:30 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 22053: (QA follow-up) More tests (4.70 KB, patch)
2019-04-29 18:30 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 22053: (QA follow-up) Override enable_plugins configuration (2.73 KB, patch)
2019-04-30 13:56 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 22053: (QA follow-up) Fix tests (1.11 KB, patch)
2019-05-10 14:52 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 22053: (QA follow-up) Fix tests (3.32 KB, patch)
2019-05-10 15:11 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Arnaud 2018-12-28 16:29:42 UTC
Today we can only disable all or none plugin by dealing with koha configuration.
It would be interesting to be able to temporarily, or not, disable one or more
without having to remove them from plugins directory. This could be useful for
plugins called by hook like "intranet_catalog_biblio_enhancements_toolbar_button"
or checkpw (see bug 20340).

Disabling is not like uninstalling. Because here we want to keep the data and
db structure created by the plugin in the case it would be enabled again.
Also, uninstalled plugin are retrieved by GetPlugins method like installed ones.

Work in progress...
Comment 1 Alex Arnaud 2018-12-28 16:53:44 UTC
Created attachment 83537 [details] [review]
Bug 22053: create unit tests
Comment 2 Alex Arnaud 2018-12-28 16:53:51 UTC
Created attachment 83538 [details] [review]
Bug 22053: ability to enable/disable some plugins

Test plan:

  - apply this patch(es),
  - launch an updatedabase,
  - go to plugins/plugins-home.pl
    and deal with enable/disable method
  - install a plugin like KitchenSink
    https://github.com/bywatersolutions/koha-plugin-kitchen-sink
  - once installed, the plugin change the background color
    of the staff client to orange.
  - disable the plugin,
  - background color should be set back to the original one
Comment 3 Alex Arnaud 2018-12-28 16:53:58 UTC
Created attachment 83539 [details] [review]
Bug 22053: update database
Comment 4 Alex Arnaud 2018-12-28 16:54:06 UTC
Created attachment 83540 [details] [review]
[DO NOT PUSH] Bug 22053: provide staff-global.css
Comment 5 Katrin Fischer 2018-12-28 22:04:29 UTC
*** Bug 21558 has been marked as a duplicate of this bug. ***
Comment 6 Katrin Fischer 2018-12-28 22:04:47 UTC
Please always check for existing bugs first ;)
Comment 7 Alex Arnaud 2018-12-29 12:34:10 UTC
(In reply to Katrin Fischer from comment #6)
> Please always check for existing bugs first ;)

I checked! But surely the wrong way >_<
There is no patch on the first one. So what do i do ? Closing this one and submit my patches on bug 21558 or i keep my patches there ?
Comment 8 Katrin Fischer 2018-12-29 14:17:08 UTC
I marked the other as a duplicate of this one - bug with patches always wins :)
Comment 9 Pierre-Marc Thibault 2019-01-04 21:55:55 UTC Comment hidden (obsolete)
Comment 10 Pierre-Marc Thibault 2019-01-04 21:55:58 UTC Comment hidden (obsolete)
Comment 11 Alex Arnaud 2019-03-25 09:02:36 UTC
Created attachment 86961 [details] [review]
Bug 22053: create unit tests

Rebased-on: 2019-03-25 Alex Arnaud <alex.arnaud@biblibre.com>
Comment 12 Alex Arnaud 2019-03-25 09:02:47 UTC
Created attachment 86962 [details] [review]
Bug 22053: ability to enable/disable some plugins

Test plan:

  - apply this patch(es),
  - launch an updatedabase,
  - go to plugins/plugins-home.pl
    and deal with enable/disable method
  - install a plugin like KitchenSink
    https://github.com/bywatersolutions/koha-plugin-kitchen-sink
  - once installed, the plugin change the background color
    of the staff client to orange.
  - disable the plugin,
  - background color should be set back to the original one

Rebased-on: 2019-03-25 Alex Arnaud <alex.arnaud@biblibre.com>
Comment 13 Alex Arnaud 2019-03-25 09:02:59 UTC
Created attachment 86963 [details] [review]
Bug 22053: update database

Rebased-on: 2019-03-25 Alex Arnaud <alex.arnaud@biblibre.com>
Comment 14 Alex Arnaud 2019-03-25 09:03:33 UTC
Created attachment 86964 [details] [review]
[DO NOT PUSH] Bug 22053: provide staff-global.css

Rebased-on: 2019-03-25 Alex Arnaud <alex.arnaud@biblibre.com>
Comment 15 Claire Gravely 2019-04-25 14:32:54 UTC
Created attachment 88783 [details] [review]
[SIGNED-OFF] Bug 22053: create unit tests

Rebased-on: 2019-03-25 Alex Arnaud <alex.arnaud@biblibre.com>

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Comment 16 Claire Gravely 2019-04-25 14:32:57 UTC
Created attachment 88784 [details] [review]
[SIGNED-OFF] Bug 22053: ability to enable/disable some plugins

Test plan:

  - apply this patch(es),
  - launch an updatedabase,
  - go to plugins/plugins-home.pl
    and deal with enable/disable method
  - install a plugin like KitchenSink
    https://github.com/bywatersolutions/koha-plugin-kitchen-sink
  - once installed, the plugin change the background color
    of the staff client to orange.
  - disable the plugin,
  - background color should be set back to the original one

Rebased-on: 2019-03-25 Alex Arnaud <alex.arnaud@biblibre.com>

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Comment 17 Claire Gravely 2019-04-25 14:33:00 UTC
Created attachment 88785 [details] [review]
[SIGNED-OFF] Bug 22053: update database

Rebased-on: 2019-03-25 Alex Arnaud <alex.arnaud@biblibre.com>

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Comment 18 Agustín Moyano 2019-04-25 22:34:28 UTC
Created attachment 88818 [details] [review]
Bug 22053: create unit tests

Rebased-on: 2019-03-25 Alex Arnaud <alex.arnaud@biblibre.com>

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Signed-off-by: Agustin Moyano <agustinmoyano@theke.io>
Comment 19 Agustín Moyano 2019-04-25 22:34:32 UTC
Created attachment 88819 [details] [review]
Bug 22053: ability to enable/disable some plugins

Test plan:

  - apply this patch(es),
  - launch an updatedabase,
  - go to plugins/plugins-home.pl
    and deal with enable/disable method
  - install a plugin like KitchenSink
    https://github.com/bywatersolutions/koha-plugin-kitchen-sink
  - once installed, the plugin change the background color
    of the staff client to orange.
  - disable the plugin,
  - background color should be set back to the original one

Rebased-on: 2019-03-25 Alex Arnaud <alex.arnaud@biblibre.com>

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Signed-off-by: Agustin Moyano <agustinmoyano@theke.io>
Comment 20 Agustín Moyano 2019-04-25 22:34:37 UTC
Created attachment 88820 [details] [review]
Bug 22053: update database

Rebased-on: 2019-03-25 Alex Arnaud <alex.arnaud@biblibre.com>

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Signed-off-by: Agustin Moyano <agustinmoyano@theke.io>
Comment 21 Agustín Moyano 2019-04-25 22:40:04 UTC
Hello Alex, awesome job!, it works great..

Just a little question..

I noticed that disabled plugins have the "run plugin" button enabled, and when you click on it works.. 

shouldn't that button be disabled if you disable the entire plugin?.. or this bug is intended only for hookup functions?
Comment 22 Agustín Moyano 2019-04-25 22:47:21 UTC
(In reply to Agustín Moyano from comment #21)
> Hello Alex, awesome job!, it works great..
> 
> Just a little question..
> 
> I noticed that disabled plugins have the "run plugin" button enabled, and
> when you click on it works.. 
> 
> shouldn't that button be disabled if you disable the entire plugin?.. or
> this bug is intended only for hookup functions?

s/"run plugin" button/"run tool" option/g

:P
Comment 23 Alex Arnaud 2019-04-26 11:02:41 UTC
(In reply to Agustín Moyano from comment #21)
> Hello Alex, awesome job!, it works great..
> 
> Just a little question..
> 
> I noticed that disabled plugins have the "run plugin" button enabled, and
> when you click on it works.. 
> 
> shouldn't that button be disabled if you disable the entire plugin?.. or
> this bug is intended only for hookup functions?

Hello Agustín,

IMO, disabled plugins can be run and configured in the "plugins area" (koha/plugins/*). The only thing this patch does is to prevent calls of disabled plugins anywhere else in Koha (hooks).

I don't see any advantage of preventing uses of run or configure methods since you can just ignore them. But a hook calls systematically all plugins implementing a specific method and you might need that does not happen for one of them until your are done with the configuration (for exemple) without removing it from your server. 

Thx for testing!
Comment 24 Tomás Cohen Arazi 2019-04-29 18:30:06 UTC
Created attachment 89040 [details] [review]
Bug 22053: create unit tests

Rebased-on: 2019-03-25 Alex Arnaud <alex.arnaud@biblibre.com>

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Signed-off-by: Agustin Moyano <agustinmoyano@theke.io>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 25 Tomás Cohen Arazi 2019-04-29 18:30:13 UTC
Created attachment 89041 [details] [review]
Bug 22053: ability to enable/disable some plugins

Test plan:

  - apply this patch(es),
  - launch an updatedabase,
  - go to plugins/plugins-home.pl
    and deal with enable/disable method
  - install a plugin like KitchenSink
    https://github.com/bywatersolutions/koha-plugin-kitchen-sink
  - once installed, the plugin change the background color
    of the staff client to orange.
  - disable the plugin,
  - background color should be set back to the original one

Rebased-on: 2019-03-25 Alex Arnaud <alex.arnaud@biblibre.com>

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Signed-off-by: Agustin Moyano <agustinmoyano@theke.io>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 26 Tomás Cohen Arazi 2019-04-29 18:30:22 UTC
Created attachment 89042 [details] [review]
Bug 22053: update database

Rebased-on: 2019-03-25 Alex Arnaud <alex.arnaud@biblibre.com>

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Signed-off-by: Agustin Moyano <agustinmoyano@theke.io>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 27 Tomás Cohen Arazi 2019-04-29 18:30:29 UTC
Created attachment 89043 [details] [review]
Bug 22053: (QA follow-up) More tests

This patch adds tests for:
- $plugin->enable and $plugin->disable are chainable (i.e. return $self)
- Disabled plugins don't inject routes

To test:
- Apply this patch
- Run:
  $ kshell
 k$ prove t/db_dependent/Koha/REST/Plugin/PluginRoutes.t \
          t/db_dependent/Plugins.t
=> SUCCESS: Tests pass

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 28 Nick Clemens 2019-04-30 13:40:12 UTC
The updatedatabase fails for installations without plugins enabled
Comment 29 Tomás Cohen Arazi 2019-04-30 13:56:08 UTC
Created attachment 89116 [details] [review]
Bug 22053: (QA follow-up) Override enable_plugins configuration

This patch makes the update script override the configured
enable_plugins setting in koha-conf.xml.

on testing the failure I wrote trivial tests on how
Koha::Plugins->new({ enable_plugins => 1 }) should work. Adding them to
this patch as well.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 30 Nick Clemens 2019-05-09 19:32:54 UTC
Awesome work all!

Pushed to master for 19.05
Comment 31 Tomás Cohen Arazi 2019-05-10 14:52:53 UTC
Created attachment 89551 [details] [review]
Bug 22053: (QA follow-up) Fix tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 32 Tomás Cohen Arazi 2019-05-10 14:53:23 UTC
@RM, follow-up fixes the tests.
Comment 33 Tomás Cohen Arazi 2019-05-10 15:11:17 UTC
Created attachment 89558 [details] [review]
Bug 22053: (QA follow-up) Fix tests

This patch makes the tests enable the plugins that are required for
them. Otherwise unexpected failures can happen

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 34 Martin Renvoize 2019-05-16 14:36:47 UTC
Enhancement will not be backported to 18.11.x series.
Comment 35 Nick Clemens 2019-05-22 14:22:32 UTC
(In reply to Tomás Cohen Arazi from comment #32)
> @RM, follow-up fixes the tests.

This has been pushed to master