<div dir="ltr">I've read the code a bit more now...<div><br></div><div>You could probably use ->_result to reach inside the object and call a store without triggering the Koha::Objects store to circumnavigate the issues here... but.. should you.. I've commented on the bug.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 10 Mar 2021 at 06:54, Renvoize, Martin <<a href="mailto:martin.renvoize@ptfs-europe.com">martin.renvoize@ptfs-europe.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Indeed, I can't see calling SUPER working here.. and I can see the issue with calling a bare 'store' as you'd end up causing a recursion..  I initially wondered about setting an internal flag in the object that you could look for in the second call to the hook, but as get pass a new copy of the object (get_from_storage) and not the object itself I can't see that working either... Hummm</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 9 Mar 2021, 8:32 am Fridolin SOMERS, <<a href="mailto:fridolin.somers@biblibre.com" target="_blank">fridolin.somers@biblibre.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Yop<br>
<br>
I've tried with :<br>
<br>
sub after_item_action {<br>
     my ( $self, $params ) = @_;<br>
     warn "AFTER ITEM ACTION";<br>
<br>
     my $item = $params->{item};<br>
     $item->itemnotes("Edited at " . localtime);<br>
}<br>
<br>
Calling $item->SUPER::store() generates an error :<br>
<br>
Plugin error (Example Kitchen-Sink Plugin): Can't locate object method <br>
"store" via package "Koha::Plugin::Com::ByWaterSolutions::KitchenSink" <br>
at <br>
/mnt/git/koha-plugin-kitchen-sink/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm <br>
line 580.<br>
<br>
Surely only Koha::Item can call SUPER.<br>
<br>
Adding $self->SUPER::store() at the end of Koha::Item->store() does also <br>
not work.<br>
<br>
Is it because of "get_from_storage" ?<br>
<br>
$self->get_from_storage->_after_item_action_hooks({ action => $action });<br>
<br>
The _after_item_action_hooks method is called not on object $self but on <br>
a copy ?<br>
<br>
Best regards,<br>
<br>
Le 08/03/2021 à 11:49, Jonathan Druart a écrit :<br>
> I wouldn't add other hooks, they are "_after_item_action_hooks" for <br>
> creation and modification.<br>
> "After item creation" should allow you to modify the item, unless we <br>
> need a "pre store" hook.<br>
> I had a look at the code and I didn't find any problems.<br>
> Fridolin, what did you try exactly, can you share the code?<br>
> <br>
> Le lun. 8 mars 2021 à 11:17, Tomas Cohen Arazi <<a href="mailto:tomascohen@gmail.com" rel="noreferrer" target="_blank">tomascohen@gmail.com</a> <br>
> <mailto:<a href="mailto:tomascohen@gmail.com" rel="noreferrer" target="_blank">tomascohen@gmail.com</a>>> a écrit :<br>
> <br>
>     Maybe you need some other hook. Ones that allows you to make changes<br>
>     to the object right before it is stored instead of this one, that<br>
>     gets the 'just updated' object.<br>
>     When I added 'after' hooks for biblios and items actions, the idea<br>
>     was that they should act as triggers for other actions: in my case,<br>
>     fill a zebraqueue-ish table my plugin uses.<br>
> <br>
>     El lun, 8 mar 2021 a las 5:11, Fridolin SOMERS<br>
>     (<<a href="mailto:fridolin.somers@biblibre.com" rel="noreferrer" target="_blank">fridolin.somers@biblibre.com</a><br>
>     <mailto:<a href="mailto:fridolin.somers@biblibre.com" rel="noreferrer" target="_blank">fridolin.somers@biblibre.com</a>>>) escribió:<br>
> <br>
>         Hi,<br>
> <br>
>         While testing new hook :<br>
>         <a href="https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066" rel="noreferrer noreferrer" target="_blank">https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066</a><br>
>         <<a href="https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066" rel="noreferrer noreferrer" target="_blank">https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066</a>><br>
> <br>
>         I faced a problem :<br>
>         How can I modify the current patron object ?<br>
>         Since we are in the store() method of that object and inside a<br>
>         transation.<br>
>         I tried to call $self->SUPER::store(); but does not work.<br>
> <br>
>         Should we implement this possiblity or document hooks to say it is<br>
>         impossible.<br>
> <br>
>         Thanks a lot for your help :D<br>
> <br>
>         Best regards,<br>
> <br>
>         -- <br>
>         Fridolin SOMERS <<a href="mailto:fridolin.somers@biblibre.com" rel="noreferrer" target="_blank">fridolin.somers@biblibre.com</a><br>
>         <mailto:<a href="mailto:fridolin.somers@biblibre.com" rel="noreferrer" target="_blank">fridolin.somers@biblibre.com</a>>><br>
>         Software and system maintainer 🦄<br>
>         BibLibre, France<br>
>         _______________________________________________<br>
>         Koha-devel mailing list<br>
>         <a href="mailto:Koha-devel@lists.koha-community.org" rel="noreferrer" target="_blank">Koha-devel@lists.koha-community.org</a><br>
>         <mailto:<a href="mailto:Koha-devel@lists.koha-community.org" rel="noreferrer" target="_blank">Koha-devel@lists.koha-community.org</a>><br>
>         <a href="https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" rel="noreferrer noreferrer" target="_blank">https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel</a><br>
>         <<a href="https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" rel="noreferrer noreferrer" target="_blank">https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel</a>><br>
>         website : <a href="https://www.koha-community.org/" rel="noreferrer noreferrer" target="_blank">https://www.koha-community.org/</a><br>
>         <<a href="https://www.koha-community.org/" rel="noreferrer noreferrer" target="_blank">https://www.koha-community.org/</a>><br>
>         git : <a href="https://git.koha-community.org/" rel="noreferrer noreferrer" target="_blank">https://git.koha-community.org/</a><br>
>         <<a href="https://git.koha-community.org/" rel="noreferrer noreferrer" target="_blank">https://git.koha-community.org/</a>><br>
>         bugs : <a href="https://bugs.koha-community.org/" rel="noreferrer noreferrer" target="_blank">https://bugs.koha-community.org/</a><br>
>         <<a href="https://bugs.koha-community.org/" rel="noreferrer noreferrer" target="_blank">https://bugs.koha-community.org/</a>><br>
> <br>
> <br>
> <br>
>     -- <br>
>     Tomás Cohen Arazi<br>
>     Theke Solutions (<a href="http://theke.io" rel="noreferrer noreferrer" target="_blank">http://theke.io</a> <<a href="http://theke.io/" rel="noreferrer noreferrer" target="_blank">http://theke.io/</a>>)<br>
>     ✆ +54 9351 3513384<br>
>     GPG: B2F3C15F<br>
>     _______________________________________________<br>
>     Koha-devel mailing list<br>
>     <a href="mailto:Koha-devel@lists.koha-community.org" rel="noreferrer" target="_blank">Koha-devel@lists.koha-community.org</a><br>
>     <mailto:<a href="mailto:Koha-devel@lists.koha-community.org" rel="noreferrer" target="_blank">Koha-devel@lists.koha-community.org</a>><br>
>     <a href="https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" rel="noreferrer noreferrer" target="_blank">https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel</a><br>
>     <<a href="https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" rel="noreferrer noreferrer" target="_blank">https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel</a>><br>
>     website : <a href="https://www.koha-community.org/" rel="noreferrer noreferrer" target="_blank">https://www.koha-community.org/</a><br>
>     <<a href="https://www.koha-community.org/" rel="noreferrer noreferrer" target="_blank">https://www.koha-community.org/</a>><br>
>     git : <a href="https://git.koha-community.org/" rel="noreferrer noreferrer" target="_blank">https://git.koha-community.org/</a> <<a href="https://git.koha-community.org/" rel="noreferrer noreferrer" target="_blank">https://git.koha-community.org/</a>><br>
>     bugs : <a href="https://bugs.koha-community.org/" rel="noreferrer noreferrer" target="_blank">https://bugs.koha-community.org/</a><br>
>     <<a href="https://bugs.koha-community.org/" rel="noreferrer noreferrer" target="_blank">https://bugs.koha-community.org/</a>><br>
> <br>
<br>
-- <br>
Fridolin SOMERS <<a href="mailto:fridolin.somers@biblibre.com" rel="noreferrer" target="_blank">fridolin.somers@biblibre.com</a>><br>
Software and system maintainer 🦄<br>
BibLibre, France<br>
_______________________________________________<br>
Koha-devel mailing list<br>
<a href="mailto:Koha-devel@lists.koha-community.org" rel="noreferrer" target="_blank">Koha-devel@lists.koha-community.org</a><br>
<a href="https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" rel="noreferrer noreferrer" target="_blank">https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel</a><br>
website : <a href="https://www.koha-community.org/" rel="noreferrer noreferrer" target="_blank">https://www.koha-community.org/</a><br>
git : <a href="https://git.koha-community.org/" rel="noreferrer noreferrer" target="_blank">https://git.koha-community.org/</a><br>
bugs : <a href="https://bugs.koha-community.org/" rel="noreferrer noreferrer" target="_blank">https://bugs.koha-community.org/</a><br>
</blockquote></div>
</blockquote></div>