Bug 32379

Summary: CRASH: Can't call method "itemlost" on an undefined value
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: trivial    
Priority: P5 - low CC: fridolin.somers
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:
23.11.00,23.05.06,22.11.12
Circulation function:
Attachments: Bug 32379: Add check on existing item
Bug 32379: Add check on existing item
Bug 32379: Add check on existing item

Description Marcel de Rooy 2022-11-30 12:06:28 UTC
21.11
    my $item = Koha::Items->find($itemnumber);
    # FIXME Handle non existent item
[L426]    my $olditemlost = $item->itemlost;

MASTER
    my $itemnumber = $input->param('itemnumber');
    my $item = Koha::Items->find($itemnumber);
    # FIXME Handle non existent item
[L535]    my $olditemlost = $item->itemlost;

Confirming the FIXME ;)
Comment 1 Marcel de Rooy 2023-11-02 10:36:49 UTC
Where was that btw?

cataloguing/additem.pl:    my $olditemlost = $item->itemlost;

L552 (current master)
    # FIXME Handle non existent item
    my $olditemlost = $item->itemlost;
Comment 2 Marcel de Rooy 2023-11-02 10:51:23 UTC
Created attachment 158240 [details] [review]
Bug 32379: Add check on existing item

Simplest fix; bail out with output_error.

Test plan:
Try /cgi-bin/koha/cataloguing/additem.pl?biblionumber=1&op=saveitem&itemnumber=999999
Note: Replace 1 by existing biblionumber, and iitem 999999 should not exist.
You should get the 404 screen now.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 3 David Nind 2023-11-02 14:10:39 UTC
Created attachment 158264 [details] [review]
Bug 32379: Add check on existing item

Simplest fix; bail out with output_error.

Test plan:
Try /cgi-bin/koha/cataloguing/additem.pl?biblionumber=1&op=saveitem&itemnumber=999999
Note: Replace 1 by existing biblionumber, and iitem 999999 should not exist.
You should get the 404 screen now.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: David Nind <david@davidnind.com>
Comment 4 Katrin Fischer 2023-11-04 13:26:36 UTC
Created attachment 158385 [details] [review]
Bug 32379: Add check on existing item

Simplest fix; bail out with output_error.

Test plan:
Try /cgi-bin/koha/cataloguing/additem.pl?biblionumber=1&op=saveitem&itemnumber=999999
Note: Replace 1 by existing biblionumber, and iitem 999999 should not exist.
You should get the 404 screen now.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 5 Tomás Cohen Arazi (tcohen) 2023-11-06 11:39:20 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 6 Fridolin Somers 2023-11-10 07:04:27 UTC
Pushed to 23.05.x for 23.05.06
Comment 7 Pedro Amorim 2023-11-14 14:49:51 UTC
Nice work everyone!

Pushed to 22.11.x for next release