Bugzilla – Attachment 142206 Details for
Bug 31873
Can't call method "safe_delete" on an undefined value at cataloguing/additem.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31873: Check ->find before calling ->safe_delete
Bug-31873-Check--find-before-calling--safedelete.patch (text/plain), 3.01 KB, created by
David Nind
on 2022-10-19 19:34:55 UTC
(
hide
)
Description:
Bug 31873: Check ->find before calling ->safe_delete
Filename:
MIME Type:
Creator:
David Nind
Created:
2022-10-19 19:34:55 UTC
Size:
3.01 KB
patch
obsolete
>From 1e35814e4265d40b3e9d7e5bc177ff556c908f00 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 19 Oct 2022 13:48:18 +0000 >Subject: [PATCH] Bug 31873: Check ->find before calling ->safe_delete > >When there is no item, you cannot safely delete it :) > >Resolve this warning: > Can't call method "safe_delete" on an undefined value at /usr/share/koha/cataloguing/additem.pl line 379 >(Line numbers may vary across versions.) > >Test plan: >Open item editor. >Add a new item. >Add another tab with same form. Delete new item. >Go back to former tab. Try to delete again. >You should see an alert now on top of the form. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: David Nind <david@davidnind.com> > >https://bugs.koha-community.org/show_bug.cgi?id=31783 >--- > cataloguing/additem.pl | 8 +++++++- > .../intranet-tmpl/prog/en/modules/cataloguing/additem.tt | 1 + > 2 files changed, 8 insertions(+), 1 deletion(-) > >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index bdd2061978..4b087aa421 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -47,6 +47,7 @@ use Storable qw( freeze thaw ); > use URI::Escape qw( uri_escape_utf8 ); > use C4::Members; > use Koha::UI::Form::Builder::Item; >+use Koha::Result::Boolean; > > use MARC::File::XML; > use URI::Escape qw( uri_escape_utf8 ); >@@ -412,7 +413,12 @@ if ($op eq "additem") { > #------------------------------------------------------------------------------- > # check that there is no issue on this item before deletion. > my $item = Koha::Items->find($itemnumber); >- my $deleted = $item->safe_delete; >+ my $deleted; >+ if( $item ) { >+ $deleted = $item->safe_delete; >+ } else { >+ $deleted = Koha::Result::Boolean->new(0)->add_message({ message => 'item_not_found' }); >+ } > if ( $deleted ) { > print $input->redirect("additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode&searchid=$searchid"); > exit; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >index b80404a420..b6d0af02f7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -69,6 +69,7 @@ > [% IF ( not_same_branch ) %]<div class="dialog alert"><strong>Cannot delete</strong>: The items do not belong to your library.</div>[% END %] > [% IF ( linked_analytics ) %]<div class="dialog alert"><strong>Cannot delete</strong>: item has linked <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]&analyze=1">analytics.</a>.</div>[% END %] > [% IF last_item_for_hold %]<div class="dialog alert"><strong>Cannot delete</strong>: Last item for bibliographic record with biblio-level hold on it.</div>[% END %] >+[% IF item_not_found %]<div class="dialog alert"><strong>Cannot delete</strong>: Item not found.</div>[% END %] > > <div id="cataloguing_additem_itemlist"> > [% IF items %] >-- >2.30.2
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 31873
:
142155
|
142206
|
143012