Bug 20829 - 'Link to host item' gives internal server error
Summary: 'Link to host item' gives internal server error
Status: Pushed to Stable
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Marcel de Rooy
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-28 21:02 UTC by Katrin Fischer
Modified: 2018-06-14 13:16 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 20829: Handle non-existent barcode when linking to host item (1.44 KB, patch)
2018-05-30 15:14 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 20829: Handle non-existent barcode when linking to host item (1.53 KB, patch)
2018-05-31 07:22 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Katrin Fischer 2018-05-28 21:02:18 UTC
To test:
- Turn on EasyAnalyticalRecords
- Go to a detail page
- Edit > Link to host item
- Enter an invalid barcode (some additional whitespace around a copied one will do it) 
- Verify it explodes into an internal server error

Error log:

Use of uninitialized value in join or string at /usr/share/perl5/MARC/Field.pm line 696.
 problem with :392 : Field 942 must have at least one subfield at /usr/share/perl5/MARC/File/XML.pm line 481.
 
<?xml version="1.0" encoding="UTF-8"?>
<record
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
    xmlns="http://www.loc.gov/MARC21/slim">

  <leader>01023nam a2200301   4500</leader>
  <controlfield tag="001">DAW28259733</controlfield>
  <controlfield tag="008">140801s2011    enk           001 0 eng |</controlfield>
  <datafield tag="020" ind1=" " ind2=" ">
    <subfield code="a">0198709463 (paperback) </subfield>
  </datafield>
  <datafield tag="020" ind1=" " ind2=" ">
    <subfield code="a">9780198709466 (paperback) </subfield>
  </datafield>
  <datafield tag="040" ind1=" " ind2=" ">
    <subfield code="d">DAWSON</subfield>
    <subfield code="e">rda</subfield>
  </datafield>
  <datafield tag="050" ind1="0" ind2="4">
    <subfield code="a">KD2079</subfield>
    <subfield code="b">.C66 2011</subfield>
  </datafield>
  <datafield tag="082" ind1="0" ind2="4">
    <subfield code="a">346.42066</subfield>
    <subfield code="2">23</subfield>
  </datafield>
  <datafield tag="245" ind1="0" ind2="0">
    <subfield code="a">Blackstone's statutes on company law 2014-2015 /</subfield>
    <subfield code="c">edited by Derek French.</subfield>
  </datafield>
  <datafield tag="250" ind1=" " ind2=" ">
    <subfield code="a">18 edition.</subfield>
  </datafield>
  <datafield tag="264" ind1=" " ind2="1">
    <subfield code="a">Oxford :</subfield>
    <subfield code="b">Oxford University Press,</subfield>
    <subfield code="c">2014.</subfield>
  </datafield>
  <datafield tag="300" ind1=" " ind2=" ">
    <subfield code="a">750 pages ;</subfield>
    <subfield code="c">25 cm.</subfield>
  </datafield>
  <datafield tag="336" ind1=" " ind2=" ">
    <subfield code="a">text</subfield>
    <subfield code="2">rdacontent</subfield>
  </datafield>
  <datafield tag="337" ind1=" " ind2=" ">
    <subfield code="a">unmediated</subfield>
    <subfield code="2">rdamedia</subfield>
  </datafield>
  <datafield tag="338" ind1=" " ind2=" ">
    <subfield code="a">volume</subfield>
    <subfield code="2">rdacarrier</subfield>
  </datafield>
  <datafield tag="490" ind1="1" ind2=" ">
    <subfield code="a">Blackstone's statutes series</subfield>
  </datafield>
  <datafield tag="500" ind1=" " ind2=" ">
    <subfield code="a">Includes index.</subfield>
  </datafield>
  <datafield tag="650" ind1=" " ind2="0">
    <subfield code="a">Corporation law</subfield>
    <subfield code="z">England.</subfield>
  </datafield>
  <datafield tag="650" ind1=" " ind2="0">
    <subfield code="a">Corporation law</subfield>
    <subfield code="z">Wales.</subfield>
  </datafield>
  <datafield tag="700" ind1="1" ind2=" ">
    <subfield code="a">French, Derek,</subfield>
    <subfield code="e">editor of compilation.</subfield>
  </datafield>
  <datafield tag="830" ind1=" " ind2="0">
    <subfield code="a">Blackstones statutes.</subfield>
  </datafield>
  <datafield tag="999" ind1=" " ind2=" ">
    <subfield code="c">392</subfield>
    <subfield code="d">392</subfield>
  </datafield>
  <datafield tag="942" ind1=" " ind2=" ">
  </datafield>
  <datafield tag="773" ind1="0" ind2=" ">
    <subfield code="0">69</subfield>
    <subfield code="9">150</subfield>
    <subfield code="a">Shetter, William Z.</subfield>
    <subfield code="b">8th ed.</subfield>
    <subfield code="d">London : Routledge, 2002.</subfield>
    <subfield code="o">39999000002850</subfield>
    <subfield code="t">Dutch :</subfield>
    <subfield code="w">(OSt)3555020</subfield>
    <subfield code="x"></subfield>
    <subfield code="z">0415235014 :</subfield>
  </datafield>
</record>
Can't call method "subfield" on an undefined value at /home/vagrant/kohaclone/cataloguing/linkitem.pl line 53.
Comment 1 Katrin Fischer 2018-05-28 21:04:30 UTC
It seems to happen more often than not, I can't get it to work correctly right now. Someone else taking a look would be appreciated!
Comment 2 M. Tompsett 2018-05-29 00:17:00 UTC
(In reply to Katrin Fischer from comment #0)
> - Verify it explodes into an internal server error

Not that I have tried, but without plack is easier to trigger internal server errors in an easily debuggable way. :)
Comment 3 Jonathan Druart 2018-05-30 15:01:19 UTC
I get a different one:

Can't call method "itemnumber" on an undefined value at /home/vagrant/kohaclone/cataloguing/linkitem.pl line 86.
Comment 4 Jonathan Druart 2018-05-30 15:14:07 UTC
Created attachment 75671 [details] [review]
Bug 20829: Handle non-existent barcode when linking to host item

Since commit 2c9aeb9b0f4449d1a25274b8fbf8dae4ec11d3bf
  Bug 18277: Remove GetBiblionumberFromItemnumber - linkitem

$item is not defined if the barcode is invalid, we should not call
method on it in that case.

Test plan:
- Turn on EasyAnalyticalRecords
- Go to a detail page
- Edit > Link to host item
- Enter an invalid barcode
=> With the patch you get a friendly error message
=> Without this patch it explodes with
Can't call method "itemnumber" on an undefined value at
/home/vagrant/kohaclone/cataloguing/linkitem.pl line 86.
Comment 5 Jonathan Druart 2018-05-30 15:14:51 UTC
Maybe the patch does not fix the original problem, but I do not recreate it.
Comment 6 Marcel de Rooy 2018-05-31 07:22:00 UTC
Created attachment 75696 [details] [review]
Bug 20829: Handle non-existent barcode when linking to host item

Since commit 2c9aeb9b0f4449d1a25274b8fbf8dae4ec11d3bf
  Bug 18277: Remove GetBiblionumberFromItemnumber - linkitem

$item is not defined if the barcode is invalid, we should not call
method on it in that case.

Test plan:
- Turn on EasyAnalyticalRecords
- Go to a detail page
- Edit > Link to host item
- Enter an invalid barcode
=> With the patch you get a friendly error message
=> Without this patch it explodes with
Can't call method "itemnumber" on an undefined value at
/home/vagrant/kohaclone/cataloguing/linkitem.pl line 86.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 7 Marcel de Rooy 2018-05-31 07:22:28 UTC
Combining SO+QA for trivial fix
Comment 8 Nick Clemens 2018-06-08 13:56:44 UTC
Pushed to master for 18.11, awesome work all!
Comment 9 Martin Renvoize 2018-06-11 09:02:03 UTC
This patch has been pushed to 18.05.x and will be in 18.05.01
Comment 10 Fridolin SOMERS 2018-06-14 13:16:54 UTC
Pushed to 17.11.x for 17.11.07