Bug 26509

Summary: Add Koha::Items->safe_delete
Product: Koha Reporter: Tomás Cohen Arazi <tomascohen>
Component: Architecture, internals, and plumbingAssignee: Tomás Cohen Arazi <tomascohen>
Status: In Discussion --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: dcook, jonathan.druart, kyle, martin.renvoize
Version: Main   
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:
Attachments: Bug 26509: Add CannotBeDeleted object exception
Bug 26509: Add Koha::Items->safe_delete
Bug 26509: Add CannotBeDeleted object exception
Bug 26509: Add Koha::Items->safe_delete
Bug 26509: Add CannotBeDeleted object exception
Bug 26509: Add Koha::Items->safe_delete
Bug 26509: Make safe_delete return the number of deleted objects

Description Tomás Cohen Arazi 2020-09-22 15:28:37 UTC
It would be handy to be able to safe_delete on an items result set. For example, if we wanted to cancel an order in the Koha:: namespace, we could just call $self->items->safe_delete;
Comment 1 Tomás Cohen Arazi 2020-09-22 16:01:08 UTC
Created attachment 110563 [details] [review]
Bug 26509: Add CannotBeDeleted object exception

This patch adds a new exception with tests for the stringification.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/Koha/Exceptions.t
=> SUCCESS: Tests pass
3. Sign off :-D
Comment 2 Tomás Cohen Arazi 2020-09-22 16:01:13 UTC
Created attachment 110564 [details] [review]
Bug 26509: Add Koha::Items->safe_delete

This patch adds a handy method that can be used to call safe_delete on a
resultset.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Items.t
=> SUCCESS: Tests pass!
3. Sign off :-D
Comment 3 Martin Renvoize 2020-09-23 08:32:45 UTC
Created attachment 110579 [details] [review]
Bug 26509: Add CannotBeDeleted object exception

This patch adds a new exception with tests for the stringification.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/Koha/Exceptions.t
=> SUCCESS: Tests pass
3. Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2020-09-23 08:32:49 UTC
Created attachment 110580 [details] [review]
Bug 26509: Add Koha::Items->safe_delete

This patch adds a handy method that can be used to call safe_delete on a
resultset.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Items.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 5 Martin Renvoize 2020-09-23 08:33:50 UTC
All works as expected.
Comment 6 Katrin Fischer 2020-09-23 20:54:36 UTC
Created attachment 110629 [details] [review]
Bug 26509: Add CannotBeDeleted object exception

This patch adds a new exception with tests for the stringification.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/Koha/Exceptions.t
=> SUCCESS: Tests pass
3. Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 7 Katrin Fischer 2020-09-23 20:54:43 UTC
Created attachment 110630 [details] [review]
Bug 26509: Add Koha::Items->safe_delete

This patch adds a handy method that can be used to call safe_delete on a
resultset.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Items.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 8 Jonathan Druart 2020-09-28 13:05:38 UTC
FYI I don't plan to push patches that add new methods which are not effectively used.
Comment 9 Tomás Cohen Arazi 2020-09-28 13:06:50 UTC
(In reply to Jonathan Druart from comment #8)
> FYI I don't plan to push patches that add new methods which are not
> effectively used.

Yes, this is part of a tree that makes use of it. This is used in bug 26515, which I'm currently rewriting.
Comment 10 Jonathan Druart 2020-10-08 10:19:17 UTC
Created attachment 111373 [details] [review]
Bug 26509: Make safe_delete return the number of deleted objects

It must the behaviour for all Koha::Objects->delete methods
Comment 11 Tomás Cohen Arazi 2020-10-15 12:48:50 UTC
There are doubts about the usefulness of this method. I dropped its use on bug 26515. Setting 'In discussion' until there's a real use for it.