Bug 26509 - Add Koha::Items->safe_delete
Summary: Add Koha::Items->safe_delete
Status: In Discussion
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-22 15:28 UTC by Tomás Cohen Arazi
Modified: 2020-10-15 12:48 UTC (History)
4 users (show)

See Also:
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 (3.07 KB, patch)
2020-09-22 16:01 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 26509: Add Koha::Items->safe_delete (4.41 KB, patch)
2020-09-22 16:01 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 26509: Add CannotBeDeleted object exception (3.13 KB, patch)
2020-09-23 08:32 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 26509: Add Koha::Items->safe_delete (4.47 KB, patch)
2020-09-23 08:32 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 26509: Add CannotBeDeleted object exception (3.19 KB, patch)
2020-09-23 20:54 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 26509: Add Koha::Items->safe_delete (4.54 KB, patch)
2020-09-23 20:54 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 26509: Make safe_delete return the number of deleted objects (2.06 KB, patch)
2020-10-08 10:19 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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.