PLACK-INTRANET-ERROR.LOG PROD [2025/09/22 10:55:07] [WARN] Odd number of elements in anonymous hash at /usr/share/koha/serials/acqui-search-result.pl line 80. Associated code: push @{$loop_basket}, { basketno => $ord->{'basketno'}, total => $ord->{'count(*)'}, authorisedby => $ord->{'authorisedby'}, creationdate => output_pref( { str => $ord->{'creationdate'} } ), closedate => output_pref( { str => $ord->{'closedate'} } ), }; Note that SearchOrders does not create a key count(*)
output_pref can generate that: Koha/DateUtils.pm:284 return if !defined $dt; # NULL date
(In reply to Jonathan Druart from comment #1) > output_pref can generate that: > Koha/DateUtils.pm:284 return if !defined $dt; # NULL date Hum, maybe not 278 if ($str) { 279 local $@; 280 $dt = eval { dt_from_string($str) }; 281 Koha::Exceptions::WrongParameter->throw("Invalid date '$str' passed to output_pref") if $@; 282 } 283 284 return if !defined $dt; # NULL date
(In reply to Jonathan Druart from comment #1) > output_pref can generate that: > Koha/DateUtils.pm:284 return if !defined $dt; # NULL date This precedes: if ($str) { local $@; $dt = eval { dt_from_string($str) }; Koha::Exceptions::WrongParameter->throw("Invalid date '$str' passed to output_pref") if $@; } We passed a str. Date comes from the db. So perhaps NULL or valid date. Should trigger an exception when wrong?
(In reply to Jonathan Druart from comment #2) > (In reply to Jonathan Druart from comment #1) > > output_pref can generate that: > > Koha/DateUtils.pm:284 return if !defined $dt; # NULL date > > Hum, maybe not > > 278 if ($str) { > 279 local $@; > 280 $dt = eval { dt_from_string($str) }; > 281 Koha::Exceptions::WrongParameter->throw("Invalid date '$str' > passed to output_pref") if $@; > 282 } > 283 > 284 return if !defined $dt; # NULL date Yes indeed :)
Created attachment 186810 [details] [review] Bug 40861: Remove warning from serials/acqui-search-result.pl Odd number of elements in anonymous hash at /kohadevbox/koha/serials/acqui-search-result.pl line 84. it's coming from closedate that is empty, and output_pref that will reach this return: 278 if ($str) { 279 local $@; 280 $dt = eval { dt_from_string($str) }; 281 Koha::Exceptions::WrongParameter->throw("Invalid date '$str' passed to output_pref") if $@; 282 } 283 284 return if !defined $dt; # NULL date if str is undef, we don't enter if l.278 and return l.284 which will shift the elements of the hash (because of the list context) We force the scalar and we are good. There was no side-effect because closedate was the last of the list. Note that total (and the 'count(*)' key) is not used in the template. Test plan: Create an order for a basket of the first vendor "My vendor" and hit http://localhost:8081/cgi-bin/koha/serials/acqui-search-result.pl?supplier=d Without this patch you get the warning Odd number of elements in anonymous hash at /kohadevbox/koha/serials/acqui-search-result.pl line 84.
Created attachment 186811 [details] [review] Bug 40861: Remove warning from serials/acqui-search-result.pl Odd number of elements in anonymous hash at /kohadevbox/koha/serials/acqui-search-result.pl line 84. it's coming from closedate that is empty, and output_pref that will reach this return: 278 if ($str) { 279 local $@; 280 $dt = eval { dt_from_string($str) }; 281 Koha::Exceptions::WrongParameter->throw("Invalid date '$str' passed to output_pref") if $@; 282 } 283 284 return if !defined $dt; # NULL date if str is undef, we don't enter if l.278 and return l.284 which will shift the elements of the hash (because of the list context) We force the scalar and we are good. There was no side-effect because closedate was the last of the list. Note that total (and the 'count(*)' key) is not used in the template. Test plan: Create an order for a basket of the first vendor "My vendor" and hit http://localhost:8081/cgi-bin/koha/serials/acqui-search-result.pl?supplier=d Without this patch you get the warning Odd number of elements in anonymous hash at /kohadevbox/koha/serials/acqui-search-result.pl line 84. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
PQA too
Nice work everyone! Pushed to main for 25.11
Nice work everyone! Pushed to 25.05.x