Bug 14122

Summary: Patron card: Software error when creating using borrower_number as parameter from URL
Product: Koha Reporter: Marc Véron <veron>
Component: Label/patron card printingAssignee: Marc Véron <veron>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: chris, mtompset, tomascohen
Version: master   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=7915
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14138
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 14138    
Attachments: Bug 14122 - Patron card: Software error when creating using borrower_number as parameter from URL
Bug 14122 - Patron card: Software error when creating using borrower_number as parameter from URL
[PASSED QA] Bug 14122 - Patron card: Software error when creating using borrower_number as parameter from URL

Description Marc Véron 2015-05-02 19:44:34 UTC
Use case: Add link to directly print a patron card from the patron's detail page.

This could be done using a URL like the following:

...cgi-bin/koha/patroncards/create-pdf.pl?borrower_number=61&template_id=24&layout_id=21&start_card=1

To test, replace the values for borrower_number, temlate_id and layout_id to something that exists in your system.

The URL leads to a software error:
Can't use an undefined value as a HASH reference at /usr/share/kohaclone/patroncards/create-pdf.pl line 118.

Reason: 
Line 92:
        push(@{$items}, {item_number => $_});
should read:
        push(@{$items}, {borrower_number => $_});

Patch follows.
Comment 1 Marc Véron 2015-05-02 19:53:19 UTC Comment hidden (obsolete)
Comment 2 Mark Tompsett 2015-05-03 07:05:02 UTC
(In reply to Marc Véron from comment #1)
> Change the values for borrower_number, template_id and layout_id to
> something that exists in your system.

Are you going to submit a bug report for the case that they don't?

<h1>Software error:</h1>
<pre>Can't bless non-reference value at /home/mtompset/kohaclone/C4/Creators/Layout.pm line 111.
</pre>
<p>
For help, please send mail to the webmaster (<a href="mailto:webmaster@debian">webmaster@debian</a>), giving this error message 
and the time and date of the error.

</p>
Comment 3 Marc Véron 2015-05-03 08:45:27 UTC
> Are you going to submit a bug report for the case that they don't?

Maybe I do not understand your question, but: No, for the case that they do...

In my example I want to print a patron card for borrower 61 with template 24 and layout 21. This fails without patch and works fine with patch.
Comment 4 Marc Véron 2015-05-04 08:28:51 UTC
Ho, forgot to set to Needs Signoff...
Comment 5 Mark Tompsett 2015-05-04 13:28:29 UTC Comment hidden (obsolete)
Comment 6 Chris Nighswonger 2015-05-04 13:32:27 UTC
(In reply to M. Tompsett from comment #5)
> NOTE: This does NOT deal with the case where borrowernumber,
> template_id, or layout_id are invalid. This only deals with
> the case where they do exist.
> 
> Invalid borrowernumber still gives same error.
> Invalid template_id or layout_id gives error on line 111.
> Those are beyond the scope of this bug.

If you don't mind, go ahead and open a bug for this. create-pdf.pl and friends should handle this gracefully.
Comment 7 Marc Véron 2015-05-04 14:16:40 UTC
I was about to open Bug 14138...

(Oh, it seems that I mistaked by setting Assignee...)
Comment 8 Katrin Fischer 2015-05-04 20:35:11 UTC
Created attachment 38828 [details] [review]
[PASSED QA] Bug 14122 - Patron card: Software error when creating using borrower_number as parameter from URL

To test prepare an URL like the following:

...cgi-bin/koha/patroncards/create-pdf.pl?borrower_number=61&template_id=24&layout_id=21&start_card=1

Change the values for borrower_number, template_id and layout_id to something that exists in your system.

Without patch, the URL leads to a software error:
Can't use an undefined value as a HASH reference at /usr/share/kohaclone/patroncards/create-pdf.pl line 118.

With patch, a PDF with the patron card is created.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

NOTE: This does NOT deal with the case where borrowernumber,
template_id, or layout_id are invalid. This only deals with
the case where they do exist.

Invalid borrowernumber still gives same error.
Invalid template_id or layout_id gives error on line 111.
Those are beyond the scope of this bug.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Nice!
Comment 9 Tomás Cohen Arazi 2015-05-06 13:44:48 UTC
Patch pushed to master.

Thanks Marc!
Comment 10 Chris Cormack 2015-05-17 05:50:50 UTC
Pushed to 3.18.x will be 3.18.7