Bug 26704

Summary: Koha::Item store triggers should utilise Koha::Object::Messages for message passing
Product: Koha Reporter: Martin Renvoize <martin.renvoize>
Component: Architecture, internals, and plumbingAssignee: Martin Renvoize <martin.renvoize>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: andrewfh, fridolin.somers, jonathan.druart, kyle, nick, tomascohen
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00
Bug Depends on: 23091, 26555    
Bug Blocks:    
Attachments: Bug 26704: Update Koha::Item to use Koha::Object::Messages
Bug 26704: Update Koha::Item to use Koha::Object::Messages
Bug 26704: Update Koha::Item to use Koha::Object::Messages
Bug 26704: Update Koha::Item to use Koha::Object::Messages
Bug 26704: Unit tests
Bug 26704: Update Koha::Item to use Koha::Object::Messages
Bug 26704: Unit tests
Bug 26704: Update Koha::Item to use Koha::Object::Messages
Bug 26704: Unit tests
Bug 26704: (follow-up) Rebase for bug 29785
Bug 26704: (follow-up) Fix t/db_dependent/Koha/Items.t
Bug 26704: (follow-up) Fix t/db_dependent/Koha/Items.t

Description Martin Renvoize 2020-10-16 09:00:38 UTC
During work on bug 18501 we introduced a way to pass back status information from the trigger action in the Koha::Item object.

We have since formalised such a procedure with the introduction of Koha::Object::Messages in bug 26555.

We should migrate the custom implementation found in Koha::Item to use the formalised version from bug 26555. This would also include the enhancements to he message passing that were added in bug 23091.
Comment 1 Martin Renvoize 2021-03-19 14:52:48 UTC
Created attachment 118548 [details] [review]
Bug 26704: Update Koha::Item to use Koha::Object::Messages
Comment 2 Martin Renvoize 2021-03-19 14:55:31 UTC
This had completely slipped off my radar until I started digging into similar message passing for Koha::Account::Line->apply improvements.

So.. I've quickly updated the code here to utilise the Koha::Object::Message handling code.

CC's Nick and Kyle in case they weren't aware of these improvements to the Koha::Object system.. I can see them being helpful more widely.
Comment 3 Martin Renvoize 2021-06-15 13:22:11 UTC
Created attachment 122004 [details] [review]
Bug 26704: Update Koha::Item to use Koha::Object::Messages
Comment 4 Martin Renvoize 2021-06-15 13:22:26 UTC
Rebased
Comment 5 Tomás Cohen Arazi 2021-06-15 14:45:03 UTC
This looks nice, and I'm glad the messages do the job! Can you give us a test plan?
Comment 6 Martin Renvoize 2021-11-29 10:51:47 UTC
Basically.. follow the test plan for bug 23091 and check that it all continues to work ;)
Comment 7 Martin Renvoize 2021-11-29 13:34:41 UTC
Created attachment 128070 [details] [review]
Bug 26704: Update Koha::Item to use Koha::Object::Messages
Comment 8 Martin Renvoize 2021-11-29 13:37:34 UTC
Rebased
Comment 9 Tomás Cohen Arazi 2021-11-29 18:20:10 UTC
Created attachment 128084 [details] [review]
Bug 26704: Update Koha::Item to use Koha::Object::Messages

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 10 Tomás Cohen Arazi 2021-11-29 18:20:16 UTC
Created attachment 128085 [details] [review]
Bug 26704: Unit tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 11 Katrin Fischer 2022-01-31 22:29:17 UTC
Created attachment 130027 [details] [review]
Bug 26704: Update Koha::Item to use Koha::Object::Messages

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 12 Katrin Fischer 2022-01-31 22:29:22 UTC
Created attachment 130028 [details] [review]
Bug 26704: Unit tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 13 Katrin Fischer 2022-01-31 22:32:46 UTC
Happy to add another sign-off: Patches apply, patches pass, QA script passes and code looks sensible. 

The commit messages are a bit bare. ;)
Comment 14 Fridolin Somers 2022-02-11 00:51:23 UTC
+ my @object_messages = @{ $updated_item->messages };
I think this needs to be adapted since Bug 29785 is pushed.

Check if there are other impacts
Comment 15 Martin Renvoize 2022-02-11 10:35:09 UTC
Created attachment 130484 [details] [review]
Bug 26704: Update Koha::Item to use Koha::Object::Messages

Use the newly introduced Koha::Object::Messages system to pass
additional information provided by object methods internally in the
objects themselves.

This patch updates the existing bespoke passing scheme to something
we've formally agreed to adopt going forward.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 16 Martin Renvoize 2022-02-11 10:35:13 UTC
Created attachment 130485 [details] [review]
Bug 26704: Unit tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 17 Martin Renvoize 2022-02-11 10:35:17 UTC
Created attachment 130486 [details] [review]
Bug 26704: (follow-up) Rebase for bug 29785

Update newly introduced calls from '->messages' to '->object_messages'

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 18 Martin Renvoize 2022-02-11 10:35:56 UTC
Rebased and follow-up added to take account of bug 29785. Ready for push :)
Comment 19 Fridolin Somers 2022-02-15 07:42:15 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 20 Jonathan Druart 2022-02-15 08:46:36 UTC
t/db_dependent/Koha/Items.t is failing because of this.
Comment 21 Fridolin Somers 2022-02-16 09:09:49 UTC
Created attachment 130657 [details] [review]
Bug 26704: (follow-up) Fix t/db_dependent/Koha/Items.t

Note this patch also fixes wrong text in test line 1295
Comment 22 Fridolin Somers 2022-02-16 09:12:10 UTC
Please validate this fix.
Comment 23 Martin Renvoize 2022-02-16 09:31:31 UTC
Created attachment 130658 [details] [review]
Bug 26704: (follow-up) Fix t/db_dependent/Koha/Items.t

Note this patch also fixes wrong text in test line 1295

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 24 Fridolin Somers 2022-02-16 10:01:08 UTC
> Bug 26704: (follow-up) Fix t/db_dependent/Koha/Items.t
Pushed to master