Bugzilla – Attachment 144925 Details for
Bug 32528
Koha::Item->safe_to_delete should short-circuit earlier
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32528: Change return logic
Bug-32528-Change-return-logic.patch (text/plain), 2.14 KB, created by
Jonathan Druart
on 2023-01-03 08:54:02 UTC
(
hide
)
Description:
Bug 32528: Change return logic
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-01-03 08:54:02 UTC
Size:
2.14 KB
patch
obsolete
>From 913a1003eb93d76141e0f228b08f15fd745c98ad Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 2 Jan 2023 15:20:04 +0100 >Subject: [PATCH] Bug 32528: Change return logic > >Back to 1 return statement >Prevent the Koha::Result::Boolean instanciation duplication >--- > Koha/Item.pm | 24 +++++++++++++++--------- > 1 file changed, 15 insertions(+), 9 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index b17f97bb32e..dae9df8f295 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -289,22 +289,24 @@ returns 1 if the item is safe to delete, > sub safe_to_delete { > my ($self) = @_; > >- return Koha::Result::Boolean->new(0)->add_message({ message => "book_on_loan" }) >- if $self->checkout; >+ my $error; > >- return Koha::Result::Boolean->new(0)->add_message({ message => "not_same_branch" }) >+ $error = "book_on_loan" if $self->checkout; >+ >+ $error //= "not_same_branch" > if defined C4::Context->userenv >- and !C4::Context->IsSuperLibrarian() >- and C4::Context->preference("IndependentBranches") >- and ( C4::Context->userenv->{branch} ne $self->homebranch ); >+ && !C4::Context->IsSuperLibrarian() >+ && C4::Context->preference("IndependentBranches") >+ && ( C4::Context->userenv->{branch} ne $self->homebranch ); > >- return Koha::Result::Boolean->new(0)->add_message({ message => "book_reserved" }) >+ # check it doesn't have a waiting reserve >+ $error //= "book_reserved" > if $self->holds->filter_by_found->count; > >- return Koha::Result::Boolean->new(0)->add_message({ message => "linked_analytics" }) >+ $error //= "linked_analytics" > if C4::Items::GetAnalyticsCount( $self->itemnumber ) > 0; > >- return Koha::Result::Boolean->new(0)->add_message({ message => "last_item_for_hold" }) >+ $error //= "last_item_for_hold" > if $self->biblio->items->count == 1 > && $self->biblio->holds->search( > { >@@ -312,6 +314,10 @@ sub safe_to_delete { > } > )->count; > >+ if ( $error ) { >+ return Koha::Result::Boolean->new(0)->add_message({ message => $error }); >+ } >+ > return Koha::Result::Boolean->new(1); > } > >-- >2.25.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 32528
:
144842
|
144847
|
144901
|
144925
|
144938