Fix :Fatal Errors occurs when date is not a regular date
authorHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Fri, 6 Mar 2009 11:03:21 +0000 (12:03 +0100)
committerGalen Charlton <galen.charlton@liblime.com>
Sat, 25 Apr 2009 03:37:04 +0000 (22:37 -0500)
When the start date or the "current date" is not a regular date
the transformation and checkdate fails because there is no
Year/Month/Date
This patch makes it fail more 'silenty' for the users and raises an
error that could be coped with.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
C4/Serials.pm

index 2cea727..5709519 100644 (file)
@@ -1806,7 +1806,7 @@ sub HasSubscriptionExpired {
          return 0 unless $res;
       my @res=split (/-/,$res);
       my @endofsubscriptiondate=split(/-/,$expirationdate);
-      return 2 if (not check_date(@res) || not check_date(@endofsubscriptiondate));
+      return 2 if (scalar(@res)!=3 || scalar(@endofsubscriptiondate)!=3||not check_date(@res) || not check_date(@endofsubscriptiondate));
       return 1 if ( (@endofsubscriptiondate && Delta_Days($res[0],$res[1],$res[2],
                   $endofsubscriptiondate[0],$endofsubscriptiondate[1],$endofsubscriptiondate[2]) <= 0)
                   || (!$res));