Bug 29410 - Dates compared arithmetically in MsgType.pm (warns: Argument isn't numeric in numeric ne)
Summary: Dates compared arithmetically in MsgType.pm (warns: Argument isn't numeric in...
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: SIP2 (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Marcel de Rooy
QA Contact: Paul Derscheid
URL:
Keywords:
Depends on: 5601
Blocks: 25790
  Show dependency treegraph
 
Reported: 2021-11-04 03:34 UTC by Andrii Nugged
Modified: 2025-03-07 14:42 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.05.00
Circulation function:


Attachments
Bug 29410: Resolve warn on numeric ne for two dates (1.29 KB, patch)
2025-03-04 14:58 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 29410: Resolve warn on numeric ne for two dates (1.31 KB, patch)
2025-03-07 10:03 UTC, Paul Derscheid
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Andrii Nugged 2021-11-04 03:34:54 UTC
Regular warnings a-la:

Argument "2021-11-04" isn't numeric in numeric ne (!=) at /usr/share/koha/lib/C4/SIP/Sip/MsgType.pm line 1265.

emitted in C4::SIP::Sip::MsgType handle_item_information sub.
Comment 1 Andrii Nugged 2021-11-05 09:11:47 UTC Comment hidden (obsolete)
Comment 2 Andrii Nugged 2021-11-05 09:12:20 UTC
there are two pieces of the code:

    if ( ( $i = $item->recall_date ) != 0 ) {
        $resp .= add_field( FID_RECALL_DATE, timestamp($i), $server );
    }
    if ( ( $i = $item->hold_pickup_date ) != 0 ) {
        $resp .= add_field( FID_HOLD_PICKUP_DATE, timestamp($i), $server );
    }


when those emits the warning,

Argument "2021-11-04" isn't numeric in numeric ne (!=) at /usr/share/koha/lib/C4/SIP/Sip/MsgType.pm

I that dumped, 'C4::SIP::ILS::Item=HASH(0x556838ade6a8)' comes with hold_pickup_date '2021-11-04' which is 'SCALAR'
Comment 3 Andrii Nugged 2021-11-06 13:46:39 UTC
more notes:

$item->due_date comes in as DateTime object once,
    '2021-12-03T23:59:00', ref: 'DateTime'
    but it also comes as scalar '0'.

$item->hold_pickup_date comes in as scalar '2021-11-11', ref: ''
    it also comes as scalar '0'.

$item->recall_date comes as scalar '0',
    I didn't yet figure out in which kind it comes when it has non-zero.
Comment 4 Jonathan Druart 2021-11-18 09:20:56 UTC
See also
  commit d4842d45601bd0f9c1bd33bf7978586ae746888f
  Bug 5601 Fix processing of DueDate return

I think it would make sense to apply the same change for both recall_date and hold_pickup_date.
Comment 5 Marcel de Rooy 2025-03-04 14:58:06 UTC
Created attachment 178920 [details] [review]
Bug 29410: Resolve warn on numeric ne for two dates

Simply, remove the !=0 test. Test for true.

Test plan:
Restart SIP.
Ask item info (SIP 17) on a waiting hold. It must have a
hold pickup date.
Check that warn disappears with this patch.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 6 Marcel de Rooy 2025-03-04 14:58:44 UTC
Trivial. Self SO

Cane across this one in 23.11. Still in master too.
Comment 7 Paul Derscheid 2025-03-07 10:03:29 UTC
Created attachment 179050 [details] [review]
Bug 29410: Resolve warn on numeric ne for two dates

Simply, remove the !=0 test. Test for true.

Test plan:
Restart SIP.
Ask item info (SIP 17) on a waiting hold. It must have a
hold pickup date.
Check that warn disappears with this patch.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 8 Katrin Fischer 2025-03-07 14:42:39 UTC
Pushed for 25.05!

Well done everyone, thank you!