Bugzilla – Attachment 145505 Details for
Bug 32418
CRASH: Can't call method "unblessed" 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 32418 - Can't call method 'unblessed' on an undefined value at cataloguing/additem.pl
Bug-32418---Cant-call-method-unblessed-on-an-undef.patch (text/plain), 5.92 KB, created by
Marcel de Rooy
on 2023-01-20 10:04:09 UTC
(
hide
)
Description:
Bug 32418 - Can't call method 'unblessed' on an undefined value at cataloguing/additem.pl
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-01-20 10:04:09 UTC
Size:
5.92 KB
patch
obsolete
>From 94c83e2a74612e390fef0d7c6291c538136ca9d8 Mon Sep 17 00:00:00 2001 >From: LMSCloudPaulD <paul.derscheid@lmscloud.de> >Date: Thu, 22 Dec 2022 14:38:54 +0100 >Subject: [PATCH] Bug 32418 - Can't call method 'unblessed' on an undefined > value at cataloguing/additem.pl >Content-Type: text/plain; charset=utf-8 > >Check whether the current op is edititem or dupeitem and if so check >whether the itemnumber supplied as a query param actually exists. > >If it doesn't, redirect to the additem op and hide all UI elements except >for a dialog that gives options to add a new item to the record or to >view the records holdings. > >This behaviour was adapted from the addbiblio view, as suggested by >Fridolin. > >To test: >1. Go to any record >2. Hit the edit button on an item in the holdings table >3. Modify the URL so that the query param for the itemnumber is either > 3.1 empty: /cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=384&itemnumber= > 3.2 an itemnumber that doesn't exist: > /cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=384&itemnumber=9999999999 > 3.3 whatever else you come up with.. >4. Check the same thing for the dupe option (op=dupeitem) >5. Sign off > >Signed-off-by: David Nind <david@davidnind.com> > >Bug 32418 - Can't call method 'unblessed' on an undefined value at cataloguing/additem.pl > >Check whether the current op is edititem or dupeitem and if so check >whether the itemnumber supplied as a query param actually exists. > >If the item is not defined we output_and_exit and save the time to >execute the rest of the controller code. Additionally we now don't have >to process the whole template anymore. > >The only caveat is that we now have the suggested actions above the >actual error message. Still an improvement. though. > >Again, thanks Frido. Hope, that this is what you had in mind. > >To test: >1. Go to any record >2. Hit the edit button on an item in the holdings table >3. Modify the URL so that the query param for the itemnumber is either > 3.1 empty: /cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=384&itemnumber= > 3.2 an itemnumber that doesn't exist: > /cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=384&itemnumber=9999999999 > 3.3 whatever else you come up with.. >4. Check the same thing for the dupe option (op=dupeitem) >5. Sign off > >Signed-off-by: David Nind <david@davidnind.com> >--- > cataloguing/additem.pl | 19 +++++++++++++------ > .../prog/en/modules/cataloguing/additem.tt | 14 +++++++++++++- > 2 files changed, 26 insertions(+), 7 deletions(-) > >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index ed31390663..760d0d774c 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -156,6 +156,14 @@ my ($template, $loggedinuser, $cookie) > flagsrequired => {editcatalogue => $userflags}, > }); > >+if ( $op eq "edititem" || $op eq "dupeitem" ) { >+ my $item = Koha::Items->find($itemnumber); >+ if ( !$item ) { >+ $itemnumber = undef; >+ $template->param( item_doesnt_exist => 1 ); >+ output_and_exit( $input, $cookie, $template, 'unknown_item' ) >+ } >+} > > # Does the user have a restricted item editing permission? > my $uid = Koha::Patrons->find( $loggedinuser )->userid; >@@ -463,20 +471,19 @@ if ($op eq "additem") { > #------------------------------------------------------------------------------- > # retrieve item if exist => then, it's a modif > $current_item = Koha::Items->find($itemnumber)->unblessed; >- # FIXME Handle non existent item >- $nextop = "saveitem"; >+ $nextop = "saveitem"; > #------------------------------------------------------------------------------- > } elsif ($op eq "dupeitem") { > #------------------------------------------------------------------------------- > # retrieve item if exist => then, it's a modif > $current_item = Koha::Items->find($itemnumber)->unblessed; >- # FIXME Handle non existent item >- if (C4::Context->preference('autoBarcode') eq 'incremental') { >- my ( $barcode ) = C4::Barcodes::ValueBuilder::incremental::get_barcode; >+ if ( C4::Context->preference('autoBarcode') eq 'incremental' ) { >+ my ($barcode) = >+ C4::Barcodes::ValueBuilder::incremental::get_barcode; > $current_item->{barcode} = $barcode; > } > else { >- $current_item->{barcode} = undef; # Don't save it! >+ $current_item->{barcode} = undef; # Don't save it! > } > > $nextop = "additem"; >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 e9a512c60e..c57a568be9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -25,7 +25,14 @@ > [% INCLUDE 'str/cataloging_additem.inc' %] > [% Asset.js("js/cataloging_additem.js") | $raw %] > <script> >- var has_item_groups = "[% item_groups.size | html %]"; >+ var has_item_groups = "[% item_groups.size | html %]"; >+ $(document).ready(function() { >+ [% IF item_doesnt_exist %] >+ $("#itemst_wrapper").hide(); >+ $("#menu").hide(); >+ $("#cataloguing_additem_newitem").hide(); >+ [% END %] >+ }); > </script> > </head> > >@@ -59,6 +66,11 @@ > <div class="row"> > <div class="col-sm-12"> > <main> >+ [% IF item_doesnt_exist %] >+ <div class="dialog alert"> >+ <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblio.biblionumber %]">Add a new item</a> or <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber %]#holdings">go to the records holdings</a>. >+ </div> >+ [% END %] > [% INCLUDE 'blocking_errors.inc' %] > <h1>Items for [% biblio.title | html %] [% IF ( biblio.author ) %] by [% biblio.author | html %][% END %] (Record #[% biblio.biblionumber | html %])</h1> > >-- >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 32418
:
144571
|
144639
|
144640
|
144641
|
144643
|
144794
|
144812
|
145306
|
145307
|
145505
|
146944
|
149092
|
149591
|
149626
|
149627
|
149635
|
149636
|
149637