[Bug 19306] New: Adding hooks to the plugin system
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 Bug ID: 19306 Summary: Adding hooks to the plugin system Change sponsored?: --- Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: stefan.berndtsson@ub.gu.se QA Contact: testopia@bugs.koha-community.org We've been working on adding hook functionality to the existing plugin system. This is very much proof-of-concept code at the moment, but here is how it works. 1. Somewhere in the code you add a hook-call with a name for that hook, and pass in some data relevant to that hook. 2. Each plugin with a method matching the hook name is called in sequence, with the data as input and returning data of similar form, which is then passed on to the next matching plugin. 3. The end result is returned back from the hook-call, is put back in place, and code execution is resumed. The PoC code adds a Koha::Plugins::Handler->run_matching() method that looks up the relevant loaded plugins (using GetPlugins) and calls Koha::Plugins::Handler->run() on each of them. If plugins are not enabled, or if there is no plugin matching the hook, the input data is returned back, resulting in unaffected operation. One hook is added in Koha::SearchEngine::Elasticsearch::QueryBuilder.pm, in build_query_compat with the name "build_query_before", which is simply run before the query parsing takes place. A very simple example plugin is available at: https://github.com/ub-digit/koha-plugin-build-query-example/releases This plugin edits a query beginning with "Provider:" to do "publisher:" instead. A simple example that when using Elasticsearch makes publisher links in the bibliographic detail view clickable. The current XSLT uses the Zebra based links, that result in an unusable search. This is not meant to be the solution to the Zebra/Elasticsearch conflict in the XSLT, but it's a simple demonstration of the hook feature. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 --- Comment #1 from Stefan Berndtsson <stefan.berndtsson@ub.gu.se> --- Created attachment 67108 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67108&action=edit Bug in run_matching when plugins are not available -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 Stefan Berndtsson <stefan.berndtsson@ub.gu.se> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67108|0 |1 is obsolete| | Attachment #67108|1 |0 is patch| | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 --- Comment #2 from Stefan Berndtsson <stefan.berndtsson@ub.gu.se> --- Created attachment 67109 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67109&action=edit Adding hooks to the plugin system -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 Viktor Sarge <viktor.sarge@regionhalland.se> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |viktor.sarge@regionhalland. | |se -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 Magnus Enger <magnus@libriotech.no> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |magnus@libriotech.no -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |katrin.fischer@bsz-bw.de --- Comment #3 from Katrin Fischer <katrin.fischer@bsz-bw.de> ---
This plugin edits a query beginning with "Provider:" to do "publisher:" instead. A simple example that when using Elasticsearch makes publisher links in the bibliographic detail view clickable. The current XSLT uses the Zebra based links, that result in an unusable search. This is not meant to be the solution to the Zebra/Elasticsearch conflict in the XSLT, but it's a simple demonstration of the hook feature.
Maybe this should be filed as a separate bug? -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kyle@bywatersolutions.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 --- Comment #4 from Kyle M Hall <kyle@bywatersolutions.com> --- This adds a very nice convenience method. I'd love to see a followup to replace the existing bespoke looks for opac hooks, staff hooks, and payment plugins if we are to add this. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 --- Comment #5 from Stefan Berndtsson <stefan.berndtsson@ub.gu.se> --- The way I see this there are three kinds of "plugins". This idea adds a fourth. 1. Report-plugin. 2. Tool-plugin. 3. "Normal" plugin. 4. "Hooks". The normal plugin is meant to run once, in a very particular circumstance where the result of the plugin isn't necessarily meant to be passed on to any other plugin. An example here is the to_marc feature used when importing records. Input can be CSV and output is MARC. A hook on the other hand is meant to return data in the same format as it was received, so that they are chainable. Multiple plugins can be available for the same hook. An example for this case could be modifying MARC-data on its way to the database (for those familiar with Rails, this would be similar to a before_save hook), or adding extra fields into the index without changing the data, in a before_index hook. We currently use the latter in our Koha instance where we want to be able to distinguish books from ebooks for example, where the qualification for these come from multiple MARC fields. The plugin used for this looks at the MARC-record, combines everything and adds a 998$a with the result which is then indexed and searchable. Many such plugins could be chained in sequence for different kinds of index-preparations. It may therefor not be sensible to replace things all throughout the code, and that 3 and 4 may need to live beside each other. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 David Gustafsson <glasklas@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |glasklas@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 Emma Ternrud <emma.ternrud@ub.gu.se> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |emma.ternrud@ub.gu.se -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 Arthur Suzuki <arthur.suzuki@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |arthur.suzuki@biblibre.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fridolin.somers@biblibre.co | |m --- Comment #6 from Fridolin Somers <fridolin.somers@biblibre.com> --- Is this implemented by Koha::Plugins->call() ? -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19306 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |In Discussion --- Comment #7 from David Cook <dcook@prosentient.com.au> --- Not sure what the status of this one is right now... so moving to "In Discussion" -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org