Bug 13109: Serial failure for received and general viewing.

to test...

1/ attempt to view a subscription-detail that has a NULL value for either it's 'startdate' or 'enddate'

  an example url would be...
  http://koha-admin.foo.org/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=1

  observe error...
  'Date::Calc::PP::Delta_Days(): Usage: Date::Calc::Delta_Days($year1,$month1,$day1,$year2,$month2,$day2) at /your/koha/C4/Serials.pm line 2325'

2/ apply patch
3/ repeat step 1/
   observe that detail page displays OK

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
I confirm the issue if startdate is null (can exist with old data,
before the js check on the form).
Amended patch: Remove trailing space char and the link to the bz number
(can be found using git log).

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
Mason James 2015-03-30 19:33:45 +13:00 committed by Tomas Cohen Arazi
parent 1a585ec7fe
commit 381959a935

View file

@ -947,7 +947,9 @@ sub GetExpirationDate {
# we don't do the same test if the subscription is based on X numbers or on X weeks/months
$enddate = $startdate || $subscription->{startdate};
my @date = split( /-/, $enddate );
return if ( scalar(@date) != 3 || not check_date(@date) );
my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($subscription->{periodicity});
if ( $frequency and $frequency->{unit} ) {
@ -2243,18 +2245,26 @@ sub abouttoexpire {
my $per = $subscription->{'periodicity'};
my $frequency = C4::Serials::Frequency::GetSubscriptionFrequency($per);
if ($frequency and $frequency->{unit}){
my $expirationdate = GetExpirationDate($subscriptionid);
my ($res) = $dbh->selectrow_array('select max(planneddate) from serial where subscriptionid = ?', undef, $subscriptionid);
my $nextdate = GetNextDate($subscription, $res);
if(Date::Calc::Delta_Days(
split( /-/, $nextdate ),
split( /-/, $expirationdate )
) <= 0) {
return 1;
# only compare dates if both dates exist.
if ($nextdate and $expirationdate) {
if(Date::Calc::Delta_Days(
split( /-/, $nextdate ),
split( /-/, $expirationdate )
) <= 0) {
return 1;
}
}
} elsif ($subscription->{numberlength}>0) {
return (countissuesfrom($subscriptionid,$subscription->{'startdate'}) >=$subscription->{numberlength}-1);
}
return 0;
}