[Koha-patches] [PATCH] Bug 5673: test guarantorid consistently

Colin Campbell colin.campbell at ptfs-europe.com
Mon Jan 31 17:19:49 CET 2011


Incorrect checking of guarantorid was causing moremember.pl to
try and construct addresses using data from non-existent guarantors
ensure that test is consistently checking that value is defined and not
'', '0' or 0 [ i.e. what perl does for you anyway!!]
---
 members/memberentry.pl  |   11 +++++------
 members/moremember.pl   |    2 +-
 members/update-child.pl |    2 +-
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/members/memberentry.pl b/members/memberentry.pl
index fbd8538..9fb8011 100755
--- a/members/memberentry.pl
+++ b/members/memberentry.pl
@@ -198,10 +198,7 @@ if (($op eq 'insert') and !$nodouble){
 }
 
   #recover all data from guarantor address phone ,fax... 
-if ( defined($guarantorid) and
-     ( $category_type eq 'C' || $category_type eq 'P' ) and
-     $guarantorid ne ''  and
-     $guarantorid ne '0' ) {
+if ( $guarantorid and ( $category_type eq 'C' || $category_type eq 'P' )) {
     if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) {
         $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
         if ( !defined($data{'contactname'}) or $data{'contactname'} eq '' or
@@ -438,7 +435,9 @@ foreach (qw(C A S P I X)) {
 $template->param('typeloop' => \@typeloop);
 
 # test in city
-$select_city=getidcity($data{'city'}) if defined $guarantorid and ($guarantorid ne '0');
+if ( $guarantorid ) {
+    $select_city = getidcity($data{city});
+}
 ($default_city=$select_city) if ($step eq 0);
 if (!defined($select_city) or $select_city eq '' ){
 	$default_city = &getidcity($data{'city'});
@@ -639,7 +638,7 @@ $template->param(
 $template->param(
   nodouble  => $nodouble,
   borrowernumber  => $borrowernumber, #register number
-  guarantorid => (defined($borrower_data->{'guarantorid'})) ? $borrower_data->{'guarantorid'} : $guarantorid,
+  guarantorid => (($borrower_data->{'guarantorid'})) ? $borrower_data->{'guarantorid'} : $guarantorid,
   ethcatpopup => $ethcatpopup,
   relshiploop => \@relshipdata,
   city_loop => $city_arrayref,
diff --git a/members/moremember.pl b/members/moremember.pl
index 7de3fb0..1cbce10 100755
--- a/members/moremember.pl
+++ b/members/moremember.pl
@@ -155,7 +155,7 @@ $data->{ "sex_".$data->{'sex'}."_p" } = 1;
 
 my $catcode;
 if ( $category_type eq 'C') {
-	if ($data->{'guarantorid'} ne '0' ) {
+	if ($data->{guarantorid} ) {
     	my $data2 = GetMember( 'borrowernumber' => $data->{'guarantorid'} );
     	foreach (qw(address city B_address B_city phone mobile zipcode country B_country)) {
     	    $data->{$_} = $data2->{$_};
diff --git a/members/update-child.pl b/members/update-child.pl
index 39e19a1..492219f 100755
--- a/members/update-child.pl
+++ b/members/update-child.pl
@@ -81,7 +81,7 @@ if ( $op eq 'multi' ) {
 
 elsif ( $op eq 'update' ) {
     my $member = GetMember('borrowernumber'=>$borrowernumber);
-    $member->{'guarantorid'}  = '0';
+    $member->{'guarantorid'}  = 0;
     $member->{'categorycode'} = $catcode;
     my $borcat = GetBorrowercategory($catcode);
     $member->{'category_type'} = $borcat->{'category_type'};
-- 
1.7.3.5



More information about the Koha-patches mailing list