Bug 30638

Summary: Odd number of elements in anonymous hash at C4/Letters.pm line 827
Product: Koha Reporter: Marcel de Rooy <m.de.rooy>
Component: Architecture, internals, and plumbingAssignee: Marcel de Rooy <m.de.rooy>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low    
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00
Circulation function:
Bug Depends on:    
Bug Blocks: 25790    
Attachments: Bug 30638: Resolve odd number in hash warn in Letters
Bug 30638: Resolve odd number in hash warn in Letters

Description Marcel de Rooy 2022-04-28 09:58:31 UTC
Originating from 20.11 warnings: Odd number of elements in anonymous hash at C4/Letters.pm line 878

output_pref({ dt => dt_from_string( $replacedby ), dateonly => $dateonly });

This is line 827 on current master.

If dt_from_string returns undef in list context, we get the odd number warn.

Also note the following lines:

if ( $letter->{ $letter_field } ) {
    $letter->{ $letter_field } =~ s/\Q<<$table.$field$filter_string_used>>\E/$replacedby_date/g;
    $letter->{ $letter_field } =~ s/\Q<<$field$filter_string_used>>\E/$replacedby_date/g;

If output_pref should correctly return undef on a NULL from dt_from_string, the undefined result triggers two warnings in the regexes.
Comment 1 Marcel de Rooy 2022-04-28 09:59:08 UTC
Probably related to 0000-00-00 in dateaccessioned. See 27768.
Comment 2 Marcel de Rooy 2022-04-28 10:07:48 UTC
Created attachment 134217 [details] [review]
Bug 30638: Resolve odd number in hash warn in Letters

Odd number of elements in anonymous hash at C4/Letters.pm line 827.

Trivial fix. Adding undefined check on result to prevent warns
on that one.

No test plan. Read the patch.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 3 Marcel de Rooy 2022-04-28 10:08:12 UTC
Trivial: self SO
Comment 4 Katrin Fischer 2022-05-06 09:11:27 UTC
This one had me puzzled a while ago - thx for the fix!
Comment 5 Katrin Fischer 2022-05-06 09:25:48 UTC
Created attachment 134717 [details] [review]
Bug 30638: Resolve odd number in hash warn in Letters

Odd number of elements in anonymous hash at C4/Letters.pm line 827.

Trivial fix. Adding undefined check on result to prevent warns
on that one.

No test plan. Read the patch.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 6 Fridolin Somers 2022-05-06 20:35:05 UTC
Pushed to master for 22.05, thanks to everybody involved ﷐[U+1F984]﷑
Comment 7 Marcel de Rooy 2022-08-16 12:29:46 UTC
No interest for stable ?