Bugzilla – Attachment 111373 Details for
Bug 26509
Add Koha::Items->safe_delete
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26509: Make safe_delete return the number of deleted objects
Bug-26509-Make-safedelete-return-the-number-of-del.patch (text/plain), 2.06 KB, created by
Jonathan Druart
on 2020-10-08 10:19:17 UTC
(
hide
)
Description:
Bug 26509: Make safe_delete return the number of deleted objects
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-10-08 10:19:17 UTC
Size:
2.06 KB
patch
obsolete
>From e47b2e4bc18c83b549dcd67e1bf3a7ea92200247 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 8 Oct 2020 12:17:55 +0200 >Subject: [PATCH] Bug 26509: Make safe_delete return the number of deleted > objects > >It must the behaviour for all Koha::Objects->delete methods >--- > Koha/Items.pm | 11 +++++++++-- > t/db_dependent/Koha/Items.t | 2 +- > 2 files changed, 10 insertions(+), 3 deletions(-) > >diff --git a/Koha/Items.pm b/Koha/Items.pm >index 7975589b25..9a0647edce 100644 >--- a/Koha/Items.pm >+++ b/Koha/Items.pm >@@ -61,10 +61,15 @@ which will be rolled back if an exception is raised. > sub safe_delete { > my ($self) = @_; > >+ my $items_deleted; >+ > try { > $self->_resultset->result_source->schema->txn_do( > sub { > while ( my $item = $self->next ) { >+ >+ next unless $item->in_storage; >+ > my $result = $item->safe_delete; > # FIXME: $item->safe_delete has a weird set of return value options: > # - a string representing the blocking condition >@@ -75,15 +80,17 @@ sub safe_delete { > reason => $result > ); > } >+ >+ $items_deleted++; > } > } > ); >- >- return; > } > catch { > $_->rethrow; > }; >+ >+ return $items_deleted; > } > > >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index ed0e4878e4..224191b429 100755 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -990,7 +990,7 @@ subtest 'safe_delete() tests' => sub { > C4::Circulation::AddReturn( $item_1->barcode ); > > my $result = $items_rs->safe_delete; >- is( $result, undef, 'Successful call returns undef' ); >+ is( $result, 2, 'Successful call returns the number of deleted items' ); > $items_rs = Koha::Items->search({ itemnumber => { -in => [ $item_1_id, $item_2_id ] } }); > is( $items_rs->count, 0, 'Successful safe delete, items are not ' ); > >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26509
:
110563
|
110564
|
110579
|
110580
|
110629
|
110630
| 111373