[Bug 27066] New: Implement Hooks for patron's updates
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 Bug ID: 27066 Summary: Implement Hooks for patron's updates Change sponsored?: --- Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Plugin architecture Assignee: koha-bugs@lists.koha-community.org Reporter: eric.begin@inLibro.com QA Contact: testopia@bugs.koha-community.org Some of our clients use external systems to populate Koha's patron information. They can use Koha's API to update patron info, however, we don't have any way (that I know of) to notify an external system when a patron info is changed in Koha. In order to allow bidirectional communications, we are planning to add hooks. This will allow creating plugins to send messages to external systems in order to fulfil the following requirements : - Update patron information stored in the borrowers table (name, address, email, etc.) - Notify an external system when a restriction is placed on a user (fines, manual restrictions, overdues, etc.) -- 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=27066 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=27066 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fridolin.somers@biblibre.co | |m --- Comment #1 from Fridolin Somers <fridolin.somers@biblibre.com> --- Since we have hooks after_item_action and after_biblio_action, I'd say add after_patron_action hook. See https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks -- 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=27066 --- Comment #2 from Maryse Simard <maryse.simard@inlibro.com> --- Created attachment 116007 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=116007&action=edit Bug 27066: Add plugin hook after_patron_action The hook is called after patron manipulations. The value of the 'action' parameter can be 'create', 'modify' or 'delete'. To test: 1. Write a simple plugin that implements at least the new after_patron_action hook. 2. Install the plugin and enable it. 3. Create, modify or delete a patron and verify that the plugin method for the hook has been called with the right parameters. -- 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=27066 --- Comment #3 from Maryse Simard <maryse.simard@inlibro.com> --- Created attachment 116008 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=116008&action=edit Bug 27066: Unit tests for after_patron_action hook Adds unit tests for the new hook. To test: prove -v t/db_dependent/Koha/Plugins/Patron.t -- 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=27066 Maryse Simard <maryse.simard@inlibro.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Text to go in the| |Adds a new plugin hook release notes| |`after_patron_action` which | |is called after creation, | |modification or deletion of | |a patron. CC| |maryse.simard@inlibro.com Assignee|koha-bugs@lists.koha-commun |maryse.simard@inlibro.com |ity.org | Status|NEW |Needs Signoff -- 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=27066 Michal Denar <black23@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |black23@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off Patch complexity|--- |Small patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #116007|0 |1 is obsolete| | --- Comment #4 from Fridolin Somers <fridolin.somers@biblibre.com> --- Created attachment 117867 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=117867&action=edit Bug 27066: Add plugin hook after_patron_action The hook is called after patron manipulations. The value of the 'action' parameter can be 'create', 'modify' or 'delete'. To test: 1. Write a simple plugin that implements at least the new after_patron_action hook. 2. Install the plugin and enable it. 3. Create, modify or delete a patron and verify that the plugin method for the hook has been called with the right parameters. Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #116008|0 |1 is obsolete| | --- Comment #5 from Fridolin Somers <fridolin.somers@biblibre.com> --- Created attachment 117868 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=117868&action=edit Bug 27066: Unit tests for after_patron_action hook Adds unit tests for the new hook. To test: prove -v t/db_dependent/Koha/Plugins/Patron.t Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 --- Comment #6 from Fridolin Somers <fridolin.somers@biblibre.com> --- Works has expected, looks a lot like "after_item_action" -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Failed QA Summary|Implement Hooks for |Implement hooks for patros |patron's updates |updates --- Comment #7 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Please document on https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks Looking at the code and comparing with the similar after_item_action hooks I wonder about the placement in the code. The implementation on bug 22709 adds the hooks before the logs are written, this adds them after. I could imagine that plugins could actually change the data, so would result in a different logging result. So I think "before" would be better. What do you think? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Implement hooks for patros |Implement hooks for patrons |updates |updates -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 --- Comment #8 from Fridolin Somers <fridolin.somers@biblibre.com> --- (In reply to Katrin Fischer from comment #7)
Please document on https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks
Looking at the code and comparing with the similar after_item_action hooks I wonder about the placement in the code.
The implementation on bug 22709 adds the hooks before the logs are written, this adds them after.
I could imagine that plugins could actually change the data, so would result in a different logging result. So I think "before" would be better. What do you think?
I agree we must have same behavior. But I see _after_item_action_hooks is at the very end of store() : https://git.koha-community.org/Koha-community/Koha/src/commit/4f96b6767a1be0... After action logs and search engine indexing. Note that a main difference is that patron store() is in a DB transaction. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tomascohen@gmail.com --- Comment #9 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to Eric Bégin from comment #0)
Some of our clients use external systems to populate Koha's patron information.
They can use Koha's API to update patron info, however, we don't have any way (that I know of) to notify an external system when a patron info is changed in Koha.
In order to allow bidirectional communications, we are planning to add hooks.
This will allow creating plugins to send messages to external systems in order to fulfil the following requirements : - Update patron information stored in the borrowers table (name, address, email, etc.) - Notify an external system when a restriction is placed on a user (fines, manual restrictions, overdues, etc.)
Hi, maybe it is an interesting opportunity to look at adding hooks for more fine grained things. Because in that hook, it seems you will end up checking all those things (DB access). And if the hooks were added to other places like when a debarment is generated, then you would have the debarment object in context, and no DB access would be required. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@ptfs-europe | |.com --- Comment #10 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- (In reply to Katrin Fischer from comment #7)
Please document on https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks
Looking at the code and comparing with the similar after_item_action hooks I wonder about the placement in the code.
The implementation on bug 22709 adds the hooks before the logs are written, this adds them after.
I could imagine that plugins could actually change the data, so would result in a different logging result. So I think "before" would be better. What do you think?
Hmmm, tl;dr I don't think 'before' or 'after' hooks should directly affect the data of the action. We probably want 'before' and 'after' hooks.. and maybe even an 'around'. Generally, a 'before' hook is for triggering actions prior to store (but not affecting the data for the store itself).. 'after' is for triggering actions after the store (like triggering zebraqueue.. again, it shouldn't affect the data of the store itself) and an around wraps the store and returns the updated data for the store to then act upon. At least, that's my vague understanding of 'before', 'after', 'around' in other frameworks? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 --- Comment #11 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- (In reply to Eric Bégin from comment #0)
- Update patron information stored in the borrowers table (name, address, email, etc.)
I would say that this plugin works perfectly for the case where you want to trigger the notification of other systems.. but I do not think, as it stands, it works for the above statement (and I'm not sure it should.. we should implement an 'around' for that in my opinion.) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 --- Comment #12 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- (In reply to Tomás Cohen Arazi from comment #9)
(In reply to Eric Bégin from comment #0)
Hi, maybe it is an interesting opportunity to look at adding hooks for more fine grained things. Because in that hook, it seems you will end up checking all those things (DB access). And if the hooks were added to other places like when a debarment is generated, then you would have the debarment object in context, and no DB access would be required.
Also agree with this.. it would be nice to add more specific hooks.. but I don't see that as a blocker for this one. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@bugs.koha-c | |ommunity.org -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 --- Comment #13 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- (In reply to Katrin Fischer from comment #7)
Please document on https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks
Looking at the code and comparing with the similar after_item_action hooks I wonder about the placement in the code.
The implementation on bug 22709 adds the hooks before the logs are written, this adds them after.
I could imagine that plugins could actually change the data, so would result in a different logging result. So I think "before" would be better. What do you think?
To come back to the original question - do we care if the plugin calls are before of after logaction and should we be consistent? :) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 --- Comment #14 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- (In reply to Katrin Fischer from comment #13)
(In reply to Katrin Fischer from comment #7)
Please document on https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks
Looking at the code and comparing with the similar after_item_action hooks I wonder about the placement in the code.
The implementation on bug 22709 adds the hooks before the logs are written, this adds them after.
I could imagine that plugins could actually change the data, so would result in a different logging result. So I think "before" would be better. What do you think?
To come back to the original question - do we care if the plugin calls are before of after logaction and should we be consistent? :)
The questions are related ;) If 'before' and 'after' actions don't affect the data of the object.. then they wont affect the actionlogs call.. so it shouldn't matter if they're before or after. Personally.. I prefer to have them as late as possible, so after, but that's just a style thing. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@bywatersolutions.com --- Comment #15 from Nick Clemens <nick@bywatersolutions.com> --- (In reply to Martin Renvoize from comment #14)
If 'before' and 'after' actions don't affect the data of the object.. then they wont affect the actionlogs call.. so it shouldn't matter if they're before or after. Personally.. I prefer to have them as late as possible, so after, but that's just a style thing.
I agree - the log should come before the after action hook - as the log is that state when Koha is done with its work The after action hook shouldn't change the data, but it seems more stable to put our log before passing the object, in case something outside does change it - we can at least record what Koha thinks the object should be -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 --- Comment #16 from Fridolin Somers <fridolin.somers@biblibre.com> --- How do we continue here ? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 --- Comment #17 from David Cook <dcook@prosentient.com.au> --- (In reply to Martin Renvoize from comment #10)
tl;dr I don't think 'before' or 'after' hooks should directly affect the data of the action.
We probably want 'before' and 'after' hooks.. and maybe even an 'around'.
Generally, a 'before' hook is for triggering actions prior to store (but not affecting the data for the store itself).. 'after' is for triggering actions after the store (like triggering zebraqueue.. again, it shouldn't affect the data of the store itself) and an around wraps the store and returns the updated data for the store to then act upon.
At least, that's my vague understanding of 'before', 'after', 'around' in other frameworks?
That's an interesting point. I hadn't thought of that... -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 --- Comment #18 from Fridolin Somers <fridolin.somers@biblibre.com> --- This hook whould be great to manage external patrons DB. How can we continue ? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 --- Comment #19 from Fridolin Somers <fridolin.somers@biblibre.com> --- Ohhhh note that patron extented attributes are not concerned. We may need a dedicated hook. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 --- Comment #20 from Fridolin Somers <fridolin.somers@biblibre.com> --- At last added to https://wiki.koha-community.org/wiki/Koha_Plugin_Hooks / Under development hooks -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |baptiste.wojtkowski@biblibr | |e.com --- Comment #21 from Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski@biblibre.com> --- Idk if we want to, but since set_password uses SUPER::store, the hook is not called when setting the password -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |caroline.cyr-la-rose@inlibr | |o.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|maryse.simard@inlibro.com |koha-bugs@lists.koha-commun | |ity.org -- 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=27066 --- Comment #22 from Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> --- This project is no longer in our priorities so I removed Maryse as assignee. Feel free to take it up! -- 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=27066 Indranil Das Gupta <indradg@l2c2.co.in> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |indradg@l2c2.co.in -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066 Baptiste Wojtkowski (bwoj) <baptiste.wojtkowski@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |baptiste.wojtkowski@biblibr |ity.org |e.com -- 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