[Bug 11221] New: New patrons are created with invalid dateofbirth value if field is left empty
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11221 Bug ID: 11221 Summary: New patrons are created with invalid dateofbirth value if field is left empty Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: major Priority: P5 - low Component: Patrons Assignee: koha-bugs@lists.koha-community.org Reporter: oleonard@myacpl.org QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com, kyle.m.hall@gmail.com If you leave the date of birth field empty when you create a new patron an invalid value is saved to the database: '0000-00-00' instead of NULL. To reproduce: 1. Create a new patron. Leave dateofbirth empty. 2. Save the record. 3. Open the record for editing. 4. Save the record without making changes. 5. Koha gives you an error: "Date of birth is invalid." According to git bisect this bug was caused by the fix for Bug 10403. I assume it was this change to SQLHelper.pm since all other changes in that bug are related to acquisitions: --- a/C4/SQLHelper.pm +++ b/C4/SQLHelper.pm @@ -406,7 +406,7 @@ sub _filter_hash{ ## supposed to be a hash of simple values, hashes of arrays could be implemented $filter_input->{$field}=format_date_in_iso($filter_input->{$field}) if $columns->{$field}{Type}=~/date/ && - $filter_input->{$field} !~C4::Dates->regexp("iso"); + ($filter_input->{$field} && $filter_input->{$field} !~C4::Dates->regexp("iso")); my ($tmpkeys, $localvalues)=_Process_Operands($filter_input->{$field},"$tablename.$field",$searchtype,$columns); -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11221 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11221 --- Comment #1 from Jonathan Druart <jonathan.druart@biblibre.com> --- Created attachment 22879 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=22879&action=edit Bug 11221: SQLHelper::_filter_hash does not manage well dates The default values for date fields is undef, so if a date field contains an empty string, we should insert NULL in the DB. The format_date_in_iso routine should be only called if a date is defined, is not equal to an empty string and does not match the iso regex. Partial test plan: 1. Create a new patron. Leave dateofbirth empty. 2. Save the record. 3. Open the record for editing. 4. Save the record without making changes. 5. Koha gives no error. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11221 Jonathan Druart <jonathan.druart@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@biblibre.co | |m Depends on| |10403 --- Comment #2 from Jonathan Druart <jonathan.druart@biblibre.com> --- I think this patch is correct but I don't have the time to provide unit tests and I don't know how to foresee all side effects. We should have several looks at this patch! -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11221 Chris Cormack <chris@bigballofwax.co.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #22879|0 |1 is obsolete| | --- Comment #3 from Chris Cormack <chris@bigballofwax.co.nz> --- Created attachment 22978 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=22978&action=edit Bug 11221: SQLHelper::_filter_hash does not manage well dates The default values for date fields is undef, so if a date field contains an empty string, we should insert NULL in the DB. The format_date_in_iso routine should be only called if a date is defined, is not equal to an empty string and does not match the iso regex. Partial test plan: 1. Create a new patron. Leave dateofbirth empty. 2. Save the record. 3. Open the record for editing. 4. Save the record without making changes. 5. Koha gives no error. Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11221 Chris Cormack <chris@bigballofwax.co.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11221 --- Comment #4 from Chris Cormack <chris@bigballofwax.co.nz> --- Created attachment 22979 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=22979&action=edit Bug 11221: Follow up adding a unit test to test handling empty strings as dates -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11221 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA Patch complexity|--- |Medium patch -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11221 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #22978|0 |1 is obsolete| | Attachment #22979|0 |1 is obsolete| | --- Comment #5 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Created attachment 22993 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=22993&action=edit [PASSED QA] Bug 11221: SQLHelper::_filter_hash does not manage well dates The default values for date fields is undef, so if a date field contains an empty string, we should insert NULL in the DB. The format_date_in_iso routine should be only called if a date is defined, is not equal to an empty string and does not match the iso regex. Partial test plan: 1. Create a new patron. Leave dateofbirth empty. 2. Save the record. 3. Open the record for editing. 4. Save the record without making changes. 5. Koha gives no error. Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Passes all tests and QA script. Now when no date is given NULL is saved to the database. Tested: - Adding a patron without date of birth - Editing the patron, entering a date of birth - Editing the patron, deleting date of birth All worked as expected. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11221 --- Comment #6 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Created attachment 22994 --> http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=22994&action=edit [PASSED QA] Bug 11221: Follow up adding a unit test to test handling empty strings as dates Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> All tests pass. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11221 Galen Charlton <gmcharlt@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master --- Comment #7 from Galen Charlton <gmcharlt@gmail.com> --- Pushed to master and 3.14.x. Thanks, Jonathan and Chris! -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org