Bug 9503 Correct name of parameter passed to parcel.pl
authorColin Campbell <colin.campbell@ptfs-europe.com>
Tue, 29 Jan 2013 11:56:15 +0000 (11:56 +0000)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Mon, 4 Feb 2013 12:45:57 +0000 (07:45 -0500)
invoiceid was being passed as invoice causing GetInvoiceDetails
to silently fail and a system error downstream when
accessing the 'orders' element of the undefined invoice

Added an error message if GetInvoiceDetails called on undef

Signed-off-by: Galen Charlton <gmc@esilibrary.com>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>

C4/Acquisition.pm
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt

index 4a03e2c..249f10d 100644 (file)
@@ -2319,9 +2319,11 @@ Orders informations are in $invoice->{orders} (array ref)
 
 sub GetInvoiceDetails {
     my ($invoiceid) = @_;
-    my $invoice;
 
-    return unless $invoiceid;
+    if ( !defined $invoiceid ) {
+        carp 'GetInvoiceDetails called without an invoiceid';
+        return;
+    }
 
     my $dbh = C4::Context->dbh;
     my $query = qq{
@@ -2333,7 +2335,7 @@ sub GetInvoiceDetails {
     my $sth = $dbh->prepare($query);
     $sth->execute($invoiceid);
 
-    $invoice = $sth->fetchrow_hashref;
+    my $invoice = $sth->fetchrow_hashref;
 
     $query = qq{
         SELECT aqorders.*, biblio.*
index e10ec8f..94d1bc7 100644 (file)
@@ -91,7 +91,7 @@
                         [% END %]
                     </td>
                                        <td>[% IF ( suggestions_loo.invoicenumber ) %]
-                                               <a href="/cgi-bin/koha/acqui/parcel.pl?invoice=[% suggestions_loo.invoicenumber %]&amp;booksellerid=[% suggestions_loo.id %]&amp;datereceived=[% suggestions_loo.datereceived %]">[% suggestions_loo.invoicenumber %]</a>
+                                               <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% suggestions_loo.invoicenumber %]&amp;booksellerid=[% suggestions_loo.id %]&amp;datereceived=[% suggestions_loo.datereceived %]">[% suggestions_loo.invoicenumber %]</a>
                                            [% ELSE %]
                                                &nbsp;
                                            [% END %]