Bugzilla – Attachment 144812 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.25 KB, created by
Paul Derscheid
on 2022-12-23 09:11:11 UTC
(
hide
)
Description:
Bug 32418 - Can't call method 'unblessed' on an undefined value at cataloguing/additem.pl
Filename:
MIME Type:
Creator:
Paul Derscheid
Created:
2022-12-23 09:11:11 UTC
Size:
5.25 KB
patch
obsolete
>From 5a1afc569f742e38ecf90629497ee8e3e5028443 Mon Sep 17 00:00:00 2001 >From: LMSCloudPaulD <paul.derscheid@lmscloud.de> >Date: Fri, 23 Dec 2022 10:07:01 +0100 >Subject: [PATCH] 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 >--- > cataloguing/additem.pl | 26 ++++++++----------- > .../prog/en/modules/cataloguing/additem.tt | 11 ++++---- > 2 files changed, 16 insertions(+), 21 deletions(-) > >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index d180823d45..760d0d774c 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -161,6 +161,7 @@ if ( $op eq "edititem" || $op eq "dupeitem" ) { > if ( !$item ) { > $itemnumber = undef; > $template->param( item_doesnt_exist => 1 ); >+ output_and_exit( $input, $cookie, $template, 'unknown_item' ) > } > } > >@@ -469,25 +470,20 @@ if ($op eq "additem") { > } elsif ($op eq "edititem") { > #------------------------------------------------------------------------------- > # retrieve item if exist => then, it's a modif >- $nextop = "additem"; >- if ($itemnumber) { >- $current_item = Koha::Items->find($itemnumber)->unblessed; >- $nextop = "saveitem"; >- } >+ $current_item = Koha::Items->find($itemnumber)->unblessed; >+ $nextop = "saveitem"; > #------------------------------------------------------------------------------- > } elsif ($op eq "dupeitem") { > #------------------------------------------------------------------------------- > # retrieve item if exist => then, it's a modif >- if ($itemnumber) { >- $current_item = Koha::Items->find($itemnumber)->unblessed; >- 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 = Koha::Items->find($itemnumber)->unblessed; >+ 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! > } > > $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 7a6f88a1ac..c57a568be9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -66,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> > >@@ -77,12 +82,6 @@ > [% 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 %] >-[% IF item_doesnt_exist %] >-<div class="dialog alert"> >-The item you are trying to access doesn't exist.<br> >-<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 %] > > <div id="cataloguing_additem_itemlist"> > [% IF items %] >-- >2.34.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 32418
:
144571
|
144639
|
144640
|
144641
|
144643
|
144794
|
144812
|
145306
|
145307
|
145505
|
146944
|
149092
|
149591
|
149626
|
149627
|
149635
|
149636
|
149637