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

On Tue, 9 Mar 2021, 8:32 am Fridolin SOMERS, <fridolin.somers@biblibre.com> wrote:
Yop

I've tried with :

sub after_item_action {
     my ( $self, $params ) = @_;
     warn "AFTER ITEM ACTION";

     my $item = $params->{item};
     $item->itemnotes("Edited at " . localtime);
}

Calling $item->SUPER::store() generates an error :

Plugin error (Example Kitchen-Sink Plugin): Can't locate object method
"store" via package "Koha::Plugin::Com::ByWaterSolutions::KitchenSink"
at
/mnt/git/koha-plugin-kitchen-sink/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm
line 580.

Surely only Koha::Item can call SUPER.

Adding $self->SUPER::store() at the end of Koha::Item->store() does also
not work.

Is it because of "get_from_storage" ?

$self->get_from_storage->_after_item_action_hooks({ action => $action });

The _after_item_action_hooks method is called not on object $self but on
a copy ?

Best regards,

Le 08/03/2021 à 11:49, Jonathan Druart a écrit :
> I wouldn't add other hooks, they are "_after_item_action_hooks" for
> creation and modification.
> "After item creation" should allow you to modify the item, unless we
> need a "pre store" hook.
> I had a look at the code and I didn't find any problems.
> Fridolin, what did you try exactly, can you share the code?
>
> Le lun. 8 mars 2021 à 11:17, Tomas Cohen Arazi <tomascohen@gmail.com
> <mailto:tomascohen@gmail.com>> a écrit :
>
>     Maybe you need some other hook. Ones that allows you to make changes
>     to the object right before it is stored instead of this one, that
>     gets the 'just updated' object.
>     When I added 'after' hooks for biblios and items actions, the idea
>     was that they should act as triggers for other actions: in my case,
>     fill a zebraqueue-ish table my plugin uses.
>
>     El lun, 8 mar 2021 a las 5:11, Fridolin SOMERS
>     (<fridolin.somers@biblibre.com
>     <mailto:fridolin.somers@biblibre.com>>) escribió:
>
>         Hi,
>
>         While testing new hook :
>         https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066
>         <https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27066>
>
>         I faced a problem :
>         How can I modify the current patron object ?
>         Since we are in the store() method of that object and inside a
>         transation.
>         I tried to call $self->SUPER::store(); but does not work.
>
>         Should we implement this possiblity or document hooks to say it is
>         impossible.
>
>         Thanks a lot for your help :D
>
>         Best regards,
>
>         --
>         Fridolin SOMERS <fridolin.somers@biblibre.com
>         <mailto:fridolin.somers@biblibre.com>>
>         Software and system maintainer 🦄
>         BibLibre, France
>         _______________________________________________
>         Koha-devel mailing list
>         Koha-devel@lists.koha-community.org
>         <mailto:Koha-devel@lists.koha-community.org>
>         https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
>         <https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel>
>         website : https://www.koha-community.org/
>         <https://www.koha-community.org/>
>         git : https://git.koha-community.org/
>         <https://git.koha-community.org/>
>         bugs : https://bugs.koha-community.org/
>         <https://bugs.koha-community.org/>
>
>
>
>     --
>     Tomás Cohen Arazi
>     Theke Solutions (http://theke.io <http://theke.io/>)
>     ✆ +54 9351 3513384
>     GPG: B2F3C15F
>     _______________________________________________
>     Koha-devel mailing list
>     Koha-devel@lists.koha-community.org
>     <mailto:Koha-devel@lists.koha-community.org>
>     https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
>     <https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel>
>     website : https://www.koha-community.org/
>     <https://www.koha-community.org/>
>     git : https://git.koha-community.org/ <https://git.koha-community.org/>
>     bugs : https://bugs.koha-community.org/
>     <https://bugs.koha-community.org/>
>

--
Fridolin SOMERS <fridolin.somers@biblibre.com>
Software and system maintainer 🦄
BibLibre, France
_______________________________________________
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/