[Bug 14936] New: Add validation for date strings to Koha::DateUtils
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 Bug ID: 14936 Summary: Add validation for date strings to Koha::DateUtils Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: gmcharlt@gmail.com Reporter: veron@veron.ch QA Contact: testopia@bugs.koha-community.org Patch to add a generic function in Koha::DateUtils to test a date string against the 'dateformat' syspref. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 --- Comment #1 from Marc Véron <veron@veron.ch> --- Created attachment 43020 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=43020&action=edit Bug 14936 - Add validation for date strings to Koha::DateUtils To test: - Apply patch - prove t/DateUtils.t Bonus test: Apply patch(es) from Bug(s) that are blocked by this Bug and test as appropriate. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #43020|0 |1 is obsolete| | --- Comment #2 from Marc Véron <veron@veron.ch> --- Created attachment 43021 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=43021&action=edit Bug 14936 - Add validation for date strings to Koha::DateUtils To test: - Apply patch - prove t/DateUtils.t Bonus test: Apply patch(es) from Bug(s) that are blocked by this Bug and test as appropriate. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |14924 Patch complexity|--- |Small patch Assignee|gmcharlt@gmail.com |veron@veron.ch Status|NEW |Needs Signoff Referenced Bugs: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14924 [Bug 14924] Remove C4::Dates from members/memberentry.pl -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |ASSIGNED -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #43021|0 |1 is obsolete| | --- Comment #3 from Marc Véron <veron@veron.ch> --- Created attachment 43027 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=43027&action=edit Bug 14936 - Add validation for date strings to Koha::DateUtils To test: - Apply patch - prove t/DateUtils.t Bonus test: Apply patch(es) from Bug(s) that are blocked by this Bug and test as appropriate. -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |14923 Referenced Bugs: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14923 [Bug 14923] Remove C4::Dates from labels/label-item-search.pl -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 Héctor Eduardo Castro Avalos <hector.hecaxmmx@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #43027|0 |1 is obsolete| | --- Comment #4 from Héctor Eduardo Castro Avalos <hector.hecaxmmx@gmail.com> --- Created attachment 43033 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=43033&action=edit [SIGNED-OFF]Bug 14936 - Add validation for date strings to Koha::DateUtils To test: - Apply patch - prove t/DateUtils.t Bonus test: Apply patch(es) from Bug(s) that are blocked by this Bug and test as appropriate. Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com> Tested in conjunction with patches 14923 and 14924 with different date formats Tested with wrong formats 32/01/1970, 00-00-0000 and 0000-00-00 Test units pass OK -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 Héctor Eduardo Castro Avalos <hector.hecaxmmx@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hector.hecaxmmx@gmail.com Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@bugs.koha-c | |ommunity.org --- Comment #5 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Marc, This is not the way to go, for several reasons. The main reason is that you c/p dt_from_string to create the new subroutine, which is bad. Then, if you have a look at dt_from_string, you will note 1 eval around the first DateTime->new (l. 156), but not around the second one (l. 164). So I think there are at least 2 better ways to know if a date is not correctly formatted: 1/ add an eval around the second DateTime->new call, the subroutine will return undef and the caller will have to check if something has been returned ; 2/ or catch the croak raised by the DateTime in the callers I don't know what I would prefer (a bit early and not drank enough tea yet). -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |In Discussion -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |http://bugs.koha-community. | |org/bugzilla3/show_bug.cgi? | |id=12072 --- Comment #6 from Marc Véron <veron@veron.ch> --- Hi Jonathan, Propositon 1/ changes the behaviour of dt_from_string. This function is spread all over the system, and we do not know what side effects it will have if we change the behavior regarding the return value. That's why I decided not to touch it at the moment. Proposition 2/ Catch a croak: Is that done by surrounding dt_from_string with an eval? (I simply do not know) My opinion is that it is much better to have a dedicated function to validate a date string. It works fine afak and it has tests. I know that it duplicates code, but that can easily be streamlined later, after we finally have added the long outstandig DD.MM.YYYY date format (Bug 12072). (In reply to Jonathan Druart from comment #5)
Marc, This is not the way to go, for several reasons. The main reason is that you c/p dt_from_string to create the new subroutine, which is bad. Then, if you have a look at dt_from_string, you will note 1 eval around the first DateTime->new (l. 156), but not around the second one (l. 164). So I think there are at least 2 better ways to know if a date is not correctly formatted: 1/ add an eval around the second DateTime->new call, the subroutine will return undef and the caller will have to check if something has been returned ; 2/ or catch the croak raised by the DateTime in the callers
I don't know what I would prefer (a bit early and not drank enough tea yet).
-- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks|14923 | Referenced Bugs: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14923 [Bug 14923] Remove C4::Dates from labels/label-item-search.pl -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks|14924 | Referenced Bugs: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14924 [Bug 14924] Remove C4::Dates from members/memberentry.pl -- You are receiving this mail because: You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14936 Marc Véron <veron@veron.ch> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|In Discussion |RESOLVED --- Comment #7 from Marc Véron <veron@veron.ch> --- Date strings can be validated by using dt_from_string inside an eval{ }. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org