[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CSV print invoices error



I am getting an error when trying to print an invoice in CSV format:

Error!
Not a HASH reference at LedgerSMB/Template/CSV.pm line 80.

I am using ledgersmb 1.3.22.


LedgerSMB::Template::CSV::preprocess() is trying to dereference a CODE
reference as a hash.

I can't think of any situation when it makes sense for preprocess() to
dereference a CODE reference, and believe it should simply return in this
situation. (but perhaps I am missing something?)

The following patch would achieve that:

--- CSV.original.pm	2012-06-17 11:13:17.000000000 +0100
+++ CSV.pm	2012-09-13 09:40:05.460722650 +0100
@@ -74,10 +74,12 @@
 			$vars = $rawvars;
 		}
 		$vars =~ s/(^ +| +$)//g;
 		$vars =~ s/"/""/g;
 		$vars = qq|"$vars"| if $vars =~ /[^0-9.+-]/;
+	} elsif ( $type eq 'CODE' ) { # a code reference makes no sense
+		return;
 	} else { # hashes and objects
 		for ( keys %{$rawvars} ) {
 			$vars->{$_} = preprocess( $rawvars->{$_} );
 		}
 	}


Perhaps a deeper problem is why preprocess() is being passed a code
reference?  With the above patch applied, I then get a different error:

file error - invoice.csv: not found at LedgerSMB/Template/CSV.pm line 122.