[Koha-bugs] [Bug 15087] make dt_from_string return undef for '0000-00-00'

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Oct 30 11:51:49 CET 2015


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15087

Jonathan Druart <jonathan.druart at bugs.koha-community.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|Needs Signoff               |Failed QA

--- Comment #4 from Jonathan Druart <jonathan.druart at bugs.koha-community.org> ---
(In reply to Bernardo Gonzalez Kriegel from comment #0)
> Current master, define circulation rule All, All any number of days,
> but left 'Hard due date' EMPTY.
> 
> Try to checkout something to a patron, you get
> 
> Can't locate object method "truncate" via package "-1" (perhaps you forgot
> to load "-1"?) at ....

Outch!

> Problem comes from GetHardDueDate, it returns
> 
> return (dt_from_string($rule->{hardduedate},
> 'iso'),$rule->{hardduedatecompare});

Yep.

> But dt_from_string returns without value in case of '0000-00-00' date,

It usually return undef when not called in a list context.

(In reply to Bernardo Gonzalez Kriegel from comment #1)
> Created attachment 44181 [details] [review]
> Bug 15087: make dt_from_string return undef for '0000-00-00'

No! :)
It is usually a bad idea to explicitly return undef, and you get a perlcritic
warning.

> I don't know if this could have side effects

That's why it's preferable not to change the return of the subroutine but the
caller(s?).

(In reply to Marc Véron from comment #3)
> At other places we did
> 
> return ( eval { dt_from_string($rule->{hardduedate},
> 'iso'),$rule->{hardduedatecompare}); };

It's a weird hack :)
dt_from_string does not return an error.

> I propose to do it here as well and postpone the change to dt_from_string
> until the C4::Dates removal is finished.

We cannot wait for a fix here as it makes the application explodes.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list