[Bug 32107] New: Send $self to Plugins->call and call discard_changes inside
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32107 Bug ID: 32107 Summary: Send $self to Plugins->call and call discard_changes inside Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Plugin architecture Assignee: koha-bugs@lists.koha-community.org Reporter: m.de.rooy@rijksmuseum.nl QA Contact: testopia@bugs.koha-community.org Resulting from a discussion on IRC and in the QA team. If there is a need for further discussion, we can continue here. The idea is: We should no longer $self->store and pass $self->get_from_storage to the ->call routine. But we should $self->store, pass $self to Plugins->call, and ->discard_changes once inside ->call to fetch timestamps and default values from DBMS. What happens after ->call? Currently, we pass a copy but continue afterwards with the old $self. Normally, we wont do much more, but this might create side-effects since we do not operate on the latest data (we ignore changes from plugins). If we pass $self, we have the latest state back after ->call. Though we are not sure if the plugin(s) did a store. If we would do a discard after the plugins loop in ->call, we actually ignore unsaved changes like we do now too and we do not disturb the plugins loop inside ->call. To make it even more explicit, we could add a parameter to ->call that controls if we do or do not discard after the plugins loop.. Side note: The execution order of plugins seems to be database insert order when I look at the code in GetPlugins. Theoretically I would rather control that differently but that could be a topic of another report. Not in this scope ;) -- 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=32107 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au, | |jonathan.druart+koha@gmail. | |com, tomascohen@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=32107 Julian Maurice <julian.maurice@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |julian.maurice@biblibre.com --- Comment #1 from Julian Maurice <julian.maurice@biblibre.com> --- (In reply to Marcel de Rooy from comment #0)
To make it even more explicit, we could add a parameter to ->call that controls if we do or do not discard after the plugins loop..
I think that Koha::Plugin::call should not do anything on its @args except passing it to plugins. It should not even care of what's in these @args. IMO its the responsibility of the caller of Koha::Plugin::call to pass the right arguments and handle the eventual side-effects correctly. -- 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=32107 --- Comment #2 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Adding a diff here from 31894
From 59ff56f2b77ed9b529e886b40bc2da63fb929a81 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Date: Tue, 25 Oct 2022 14:45:57 +0000 Subject: [PATCH] Bug 31894: (QA follow-up) Remove unneeded get_from_storage calls Content-Type: text/plain; charset=utf-8
Test plan: Run test again. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Koha/Hold.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 8379e3f718..36b434ed2b 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -204,7 +204,7 @@ sub set_transfer { 'after_hold_action', { action => 'transfer', - payload => { hold => $self->get_from_storage } + payload => { hold => $self } } ); @@ -269,7 +269,7 @@ sub set_waiting { 'after_hold_action', { action => 'waiting', - payload => { hold => $self->get_from_storage } + payload => { hold => $self } } ); @@ -365,7 +365,7 @@ sub set_processing { 'after_hold_action', { action => 'processing', - payload => { hold => $self->get_from_storage } + payload => { hold => $self } } ); -- 2.30.2 -- 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=32107 --- Comment #3 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- (In reply to Julian Maurice from comment #1)
(In reply to Marcel de Rooy from comment #0)
To make it even more explicit, we could add a parameter to ->call that controls if we do or do not discard after the plugins loop..
I think that Koha::Plugin::call should not do anything on its @args except passing it to plugins. It should not even care of what's in these @args. IMO its the responsibility of the caller of Koha::Plugin::call to pass the right arguments and handle the eventual side-effects correctly.
Yes, I appreciate that principle. But the problem is that we are inserting more and more calls to Plugins->call and that we are loosing consistency. So we are looking for a balance here.. -- 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=32107 --- Comment #4 from Julian Maurice <julian.maurice@biblibre.com> ---
Yes, I appreciate that principle. But the problem is that we are inserting more and more calls to Plugins->call and that we are loosing consistency. So we are looking for a balance here..
Maybe adding a "wrapper subroutine" around `call` would work ? It would keep the `call` subroutine simple and data-agnostic while removing the boilerplate eventually needed everywhere Koha::Objects are passed to plugins. -- 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=32107 --- Comment #5 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- (In reply to Julian Maurice from comment #4)
Yes, I appreciate that principle. But the problem is that we are inserting more and more calls to Plugins->call and that we are loosing consistency. So we are looking for a balance here..
Maybe adding a "wrapper subroutine" around `call` would work ? It would keep the `call` subroutine simple and data-agnostic while removing the boilerplate eventually needed everywhere Koha::Objects are passed to plugins.
Good idea. -- 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