Bug 14122 - Patron card: Software error when creating using borrower_number as parameter from URL
Summary: Patron card: Software error when creating using borrower_number as parameter ...
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Label/patron card printing (show other bugs)
Version: master
Hardware: All All
: P5 - low minor (vote)
Assignee: Marc Véron
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 14138
  Show dependency treegraph
 
Reported: 2015-05-02 19:44 UTC by Marc Véron
Modified: 2015-12-03 22:02 UTC (History)
3 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 14122 - Patron card: Software error when creating using borrower_number as parameter from URL (1.19 KB, patch)
2015-05-02 19:53 UTC, Marc Véron
Details | Diff | Splinter Review
Bug 14122 - Patron card: Software error when creating using borrower_number as parameter from URL (1.53 KB, patch)
2015-05-04 13:28 UTC, M. Tompsett
Details | Diff | Splinter Review
[PASSED QA] Bug 14122 - Patron card: Software error when creating using borrower_number as parameter from URL (1.60 KB, patch)
2015-05-04 20:35 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 M. 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 M. 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