[Koha-bugs] [Bug 34713] New: Standardize plugin hooks

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue Sep 5 12:50:07 CEST 2023


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34713

            Bug ID: 34713
           Summary: Standardize plugin hooks
 Change sponsored?: ---
           Product: Koha
           Version: master
          Hardware: All
                OS: All
            Status: In Discussion
          Severity: enhancement
          Priority: P5 - low
         Component: Architecture, internals, and plumbing
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: pedro.amorim at ptfs-europe.com
        QA Contact: testopia at bugs.koha-community.org
                CC: jonathan.druart+koha at gmail.com,
                    katrin.fischer at bsz-bw.de, m.de.rooy at rijksmuseum.nl,
                    martin.renvoize at ptfs-europe.com,
                    nick at bywatersolutions.com, oleonard at myacpl.org,
                    tomascohen at gmail.com

We should standardize the way plugin hooks are implemented and behave.

Looking at:
https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks
https://github.com/bywatersolutions/dev-koha-plugin-kitchen-sink

Some hooks are called like:
Koha::Plugins->new()->GetPlugins( { method => 'background_tasks', } );
and then the respective method invoked

Others are just called like:
Koha::Plugins->call('patron_barcode_transform', \$patron_id );

Some hooks return stuff (e.g. opac_detail_xslt_variables), others expect the
param to be a ref and change in place without returning anything (e.g.
patron_barcode_transform)

---

Discussion:

We already have hooks that behave like actions, and others that behave like
filters. Wordpress put's it this way:
- an action interrupts the code flow to do something, and then returns back to
the normal flow without modifying anything;
- a filter is used to modify something in a specific way so that the
modification is then used by code later on.

My proposal is:
- Make it clear that a hook is either an action or a filter, either by name or
by the way it's called
- All actions should implement the same (example) Plugins->call('action_name',
$args) signature
- All filters should implement the same (example) Plugins->call('filter_name',
$args) signature and return $args

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.


More information about the Koha-bugs mailing list