[Koha] Date problem - tracing from HTML through perl files

Greg Vickers daehenoc at optusnet.com.au
Thu May 17 00:49:53 NZST 2007


Hi all,

I'm trying to find where Koha 2.2.9 is failing when we create a new 
user. I'm going to trace it through from the HTML page right through the 
perl files that get called. I'll document my progress in this email and 
I'll find the problem (eventually) or someone will be able to give me a 
helping hand.

OK, logging on to Koha and going Members -> Add Members 
(http://<sanitized>/cgi-bin/koha/members/memberentry.pl?actionType=Add)

Entering:
Member#: dmn01
Given Names: Delete Me
Surname: Now
Postal Address: somewhere
Town: Else

Leaving all other fields blank and clicking the 'Save' button gives:
Card number: dmn01
...
Joined: ,
Expires:

Joined and Expires dates are not automatically calculated. Librarians 
can manually enter these fields but it's a pain since the system used to 
automatically calculate them.

Even if I manually enter a date into Joined when creating a new member, 
the Expires field is still blank after the user is created.

Tracing through memberentry.pl, so long as $nok remains undefined then 
we get to here:
my $query="Select * from borrowers where borrowernumber=?";
my $sth=$dbh->prepare($query);
$sth->execute($data{'borrowernumber'});
if (my $data2=$sth->fetchrow_hashref){
    &modmember(%data);
}else{
    $borrowernumber = &newmember(%data);
}

So I assume that $data2 is undefined when creating a new member and we 
call newmember with the array %data. Which is newmember.pl in the same 
directory as memberentry.pl ... bla bla bla ...

Following newmember.pl we get to this:
if ($data{'joining'} eq ''){
     $data{'joining'}=ParseDate('today');
     $data{'joining'}=format_date($data{'joining'});
}

Running this line at the command prompt:
perl -MDate::Manip -e 'print(ParseDate('today'));'
spits out this string: 2007051622:19:35

So ParseDate appears to return a string, but I don't know if it is in 
the correct format.

BTW our Koha system preference for date is set to ISO.

Digging through the Koha module C4::Date (intranet/modules/C4/Date.pm) 
to see how format_date works, we get this:
my ($year,$month,$day)=Parse_Date($olddate);

Now Parse_Date in C4::Date comes from:
use Date::Calc qw(Parse_Date Decode_Date_EU Decode_Date_US Time_to_Date 
check_date);

Reading the Perl CPAN page about Parse_Date I wrote this code:

~ cat runme.pl
#!/usr/bin/perl -w

use Date::Manip;
use Date::Calc qw(Parse_Date Decode_Date_EU Decode_Date_US Time_to_Date 
check_date);

$date = ParseDate('today');
print $date."\n";

my ($year,$month,$day)=Parse_Date($date);
print "Year: $year\n";
print "Month: $month\n";
print "Day: $day\n";

And surprise, surprise, we get the following output:
./runme.pl
2007051622:29:53
Use of uninitialized value in concatenation (.) or string at ./runme.pl 
line 10.
Year:
Use of uninitialized value in concatenation (.) or string at ./runme.pl 
line 11.
Month:
Use of uninitialized value in concatenation (.) or string at ./runme.pl 
line 12.
Day:

Bastard. $year, $month and $day are all undefined. So Parse_Date is 
failing to parse 2007051622:29:53 correctly. What the feck do I do to 
correct it? Any suggestions about the best course of attack? I could 
just go in with a crowbar but I'd like some suggestions first :)

Anyway, I'm going to bed now :)

Thanks,
Greg


More information about the Koha mailing list