From 6f996025763c1237c7ce2ce8e72078a87476ffb3 Mon Sep 17 00:00:00 2001 From: rangi Date: Thu, 23 Oct 2003 20:26:56 +0000 Subject: [PATCH] Fix for bug 631, race conditions on borrowernumber when entering a new borrower. Depends on borrowernumber having auto_increment set in the database --- insertdata.pl | 11 ++++++----- memberentry.pl | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/insertdata.pl b/insertdata.pl index 28ac495e8f..061a29e6a2 100755 --- a/insertdata.pl +++ b/insertdata.pl @@ -45,9 +45,9 @@ foreach my $key (@names){ $data{$key}=~ s/\"/\\\"/g; } my $dbh = C4::Context->dbh; -my $query="Select * from borrowers where borrowernumber=$data{'borrowernumber'}"; +my $query="Select * from borrowers where borrowernumber=?"; my $sth=$dbh->prepare($query); -$sth->execute; +$sth->execute($data{'borrowernumber'}); if (my $data2=$sth->fetchrow_hashref){ $data{'dateofbirth'}=format_date_in_iso($data{'dateofbirth'}); $data{'joining'}=format_date_in_iso($data{'joining'}); @@ -70,16 +70,17 @@ if (my $data2=$sth->fetchrow_hashref){ $data{'dateofbirth'}=format_date_in_iso($data{'dateofbirth'}); $data{'joining'}=format_date_in_iso($data{'joining'}); $data{'expiry'}=format_date_in_iso($data{'expiry'}); + $data{'borrowernumber'}=NewBorrowerNumber(); $query="insert into borrowers (title,expiry,cardnumber,sex,ethnotes,streetaddress,faxnumber, firstname,altnotes,dateofbirth,contactname,emailaddress,textmessaging,dateenrolled,streetcity, altrelationship,othernames,phoneday,categorycode,city,area,phone,borrowernotes,altphone,surname, - initials,ethnicity,borrowernumber,physstreet,branchcode,zipcode,homezipcode) values ('$data{'title'}','$data{'expiry'}','$data{'cardnumber'}', + initials,ethnicity,physstreet,branchcode,zipcode,homezipcode) values ('$data{'title'}','$data{'expiry'}','$data{'cardnumber'}', '$data{'sex'}','$data{'ethnotes'}','$data{'address'}','$data{'faxnumber'}', '$data{'firstname'}','$data{'altnotes'}','$data{'dateofbirth'}','$data{'contactname'}','$data{'emailaddress'}','$data{'textmessaging'}', '$data{'joining'}','$data{'streetcity'}','$data{'altrelationship'}','$data{'othernames'}', '$data{'phoneday'}','$data{'categorycode'}','$data{'city'}','$data{'area'}','$data{'phone'}', '$data{'borrowernotes'}','$data{'altphone'}','$data{'surname'}','$data{'initials'}', - '$data{'ethnicity'}','$data{'borrowernumber'}','$data{'streetaddress'}','$data{'branchcode'}','$data{'zipcode'}','$data{'homezipcode'}')"; + '$data{'ethnicity'}','$data{'streetaddress'}','$data{'branchcode'}','$data{'zipcode'}','$data{'homezipcode'}')"; } # ok if its an adult (type) it may have borrowers that depend on it as a guarantor # so when we update information for an adult we should check for guarantees and update the relevant part @@ -103,7 +104,7 @@ if ($data{'categorycode'} eq 'A' || $data{'categorycode'} eq 'W'){ } } -#print $query; +warn $query; my $sth2=$dbh->prepare($query); $sth2->execute; $sth2->finish; diff --git a/memberentry.pl b/memberentry.pl index 2fa8ce1ac0..dbf03ea7a4 100755 --- a/memberentry.pl +++ b/memberentry.pl @@ -50,9 +50,9 @@ my ($template, $loggedinuser, $cookie) }); my $member=$input->param('bornum'); -if ($member eq ''){ - $member=NewBorrowerNumber(); -} +# if ($member eq ''){ +# $member=NewBorrowerNumber(); +# } my $type=$input->param('type') || ''; my $modify=$input->param('modify'); my $delete=$input->param('delete'); -- 2.39.5