Bug 10843

Summary: print a slip can cause an error
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: gitbot, gmcharlt, katrin.fischer, srdjan, tomascohen
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 10298    
Bug Blocks:    
Attachments: Bug 10843: the DateTime->add method takes a scalar, not undef
Bug 10843: the DateTime->add method takes a scalar, not undef
[SIGNED-OFF] Bug 10843: the DateTime->add method takes a scalar, not undef
[PASSED QA] Bug 10843: the DateTime->add method takes a scalar, not undef

Description Jonathan Druart 2013-09-09 12:10:22 UTC
Testing bug 10731, I found a bug:
If the pref ReservesMaxPickUpDelay is not defined, C4::Letters::_parseletter raises an error in some cases.
Comment 1 Jonathan Druart 2013-09-09 12:22:15 UTC Comment hidden (obsolete)
Comment 2 I'm just a bot 2013-09-29 05:54:48 UTC
Patch applied cleanly, go forth and signoff
Comment 3 Srdjan Jankovic 2013-09-30 05:42:58 UTC
Why // 0? An empty string would break it too, so I believe || 0 is better.
Comment 4 Jonathan Druart 2013-09-30 09:09:39 UTC
(In reply to Srdjan Jankovic from comment #3)
> Why // 0? An empty string would break it too, so I believe || 0 is better.

Yes, you are right!
I will fix it.
Comment 5 Jonathan Druart 2013-09-30 09:09:52 UTC Comment hidden (obsolete)
Comment 6 Srdjan Jankovic 2013-09-30 23:15:07 UTC Comment hidden (obsolete)
Comment 7 Katrin Fischer 2013-10-05 19:29:28 UTC
The tests pass, but there are a lot of warnings. Could you take a look, Jonathan?
Use of uninitialized value $_ in pattern match (m//) at /home/katrin/kohaclone/Koha/DateUtils.pm line 128.
Use of uninitialized value $_ in pattern match (m//) at /home/katrin/kohaclone/Koha/DateUtils.pm line 133.
Use of uninitialized value $_ in pattern match (m//) at /home/katrin/kohaclone/Koha/DateUtils.pm line 138.
Use of uninitialized value $date_format in string eq at /home/katrin/kohaclone/Koha/DateUtils.pm line 67.
Use of uninitialized value $date_format in string eq at /home/katrin/kohaclone/Koha/DateUtils.pm line 72.
Use of uninitialized value $date_format in string eq at /home/katrin/kohaclone/Koha/DateUtils.pm line 77.
Use of uninitialized value $date_format in string eq at /home/katrin/kohaclone/Koha/DateUtils.pm line 80.
Use of uninitialized value $_ in pattern match (m//) at /home/katrin/kohaclone/Koha/DateUtils.pm line 128.
Use of uninitialized value $_ in pattern match (m//) at /home/katrin/kohaclone/Koha/DateUtils.pm line 133.
Use of uninitialized value $_ in pattern match (m//) at /home/katrin/kohaclone/Koha/DateUtils.pm line 138.
Comment 8 Katrin Fischer 2013-10-05 19:41:15 UTC
Created attachment 21825 [details] [review]
[PASSED QA] Bug 10843: the DateTime->add method takes a scalar, not undef

Test plan:
1) set an empty string for the ReservesMaxPickUpDelay pref
2) place a hold on an item
3) check in the item
4) click on "Print and confirm"
5) an error occurs
> The 'days' parameter (undef) to DateTime::Duration::new was an 'undef'
6) apply the patch
7) repeat steps 1 to 4
8) the error does not occur anymore.

Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
An empty string didn't do it for me, I had to set the
variable for the systempreference to NULL. I am not sure
if this can happen when editing from the interface, but
this change should not have any ill side effects and it has
unit tests!
Comment 9 Galen Charlton 2013-10-18 06:19:07 UTC
Pushed to master.  Thanks, Jonathan!
Comment 10 Tomás Cohen Arazi 2013-12-05 13:00:41 UTC
This patch has been pushed to 3.12.x, will be in 3.12.8.

Thanks Jonathan!