From 8c8fd95a410997dedbc6e0b7392b722f7ee6c795 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 10 Mar 2014 14:20:45 +0100 Subject: [PATCH] Bug 11917: upload image - catch error if cardnumber does not exist. On uploading a patron image, if the given cardnumber does not exist, a software error is raised DBD::mysql::st execute failed: Column 'borrowernumber' cannot be null at /home/koha/src/C4/Members.pm line 1916. Test plan: SET DEBUG=1 in your apache configuration go on tools/picture-upload.pl, choose an image and put a cardnumber which does not exist in DB. With the patch, you should get a friendly error message. --- tools/picture-upload.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/picture-upload.pl b/tools/picture-upload.pl index b2aa18a..ab2692a 100755 --- a/tools/picture-upload.pl +++ b/tools/picture-upload.pl @@ -258,7 +258,10 @@ sub handle_file { $debug and warn "Image is of mimetype $mimetype"; my $dberror; if ($mimetype) { - $dberror = PutPatronImage( $cardnumber, $mimetype, $imgfile ); + $dberror = eval { + PutPatronImage( $cardnumber, $mimetype, $imgfile ); + }; + $dberror = $@ if $@; } if ( !$dberror && $mimetype ) { # Errors from here on are fatal only to the import of a particular image, so don't bail, just note the error and keep going $count{count}++; -- 1.7.10.4