Bug 21141 - Batch item modification tool throws error 500 when an itemnumber is invalid
Summary: Batch item modification tool throws error 500 when an itemnumber is invalid
Status: Pushed to Stable
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on: 18262
Blocks:
  Show dependency treegraph
 
Reported: 2018-08-01 19:18 UTC by Victor Grousset/tuxayo
Modified: 2018-08-10 07:42 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 21151: Fix SRU search fields mapping pop-up (2.93 KB, patch)
2018-08-02 22:48 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 21141: Handle non-existent itemnumbers in batch item modification/deletion (7.86 KB, patch)
2018-08-06 18:32 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 21141: Handle non-existent itemnumbers in batch item modification/deletion (7.89 KB, patch)
2018-08-07 13:52 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 21141: Handle non-existent itemnumbers in batch item modification/deletion (7.95 KB, patch)
2018-08-08 09:57 UTC, Julian Maurice
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Victor Grousset/tuxayo 2018-08-01 19:18:13 UTC
Error example:

Can't call method "title" on an undefined value at /home/koha/src/tools/batchMod.pl line 591, <$fh> line 6.


== Test plan ==
1. Create a file named valid-itemnumbers.csv with valid itemnumbers
   With the following structure:
5456
5495
6546
2. Go to Staff › Tools › Batch item modification
3. Tick "Item number file"
4. Upload the file (click "continue")
5. See that it works
6. Create a file named invalid-itemnumbers.csv with invalid itemnumbers
7. Retry
8. See that it fails
Comment 1 Victor Grousset/tuxayo 2018-08-01 19:19:02 UTC
Actually just one invalid itemnumber is enough.
Comment 2 Victor Grousset/tuxayo 2018-08-01 19:21:04 UTC
I'm not sure to work on this. Anyone can feel free to take it.
Comment 3 Victor Grousset/tuxayo 2018-08-01 19:22:27 UTC
Details:

Error is here:

https://gitlab.com/koha-community/Koha/blob/ce96080f3005be5a63c9f2cab8d4b6c81e9b5b27/tools/batchMod.pl#L580

Because $biblio is undef
Because $itemdata is undef (or empty I forgot)
Comment 4 Victor Grousset/tuxayo 2018-08-01 19:23:52 UTC
Note that when uploading a barcode file, there is an error handling logic which displays the invalid numbers. So the fix could be built from there.
Comment 5 Katrin Fischer 2018-08-02 22:48:55 UTC Comment hidden (obsolete)
Comment 6 Katrin Fischer 2018-08-02 22:50:55 UTC Comment hidden (obsolete)
Comment 7 Jonathan Druart 2018-08-06 18:28:21 UTC
Caused by
  commit bd3b1c1a33e4bb14bbcd10a0fcf871b39362430d
  Bug 18262: Koha::Biblio - Remove GetBiblioData - part 1
Comment 8 Jonathan Druart 2018-08-06 18:32:23 UTC
Created attachment 77497 [details] [review]
Bug 21141: Handle non-existent itemnumbers in batch item modification/deletion

The itemnumber list passed from a file in the batch item
modification/deletion tools is not tested.
Like barcodes we should make sure they refer to a valid items in the DB.

Test plan:
- Create a file with barcodes, itemnumbers and random lines
- Use the batch item modification and deletion tools with this file
You should see a table with a list of invalid barcodes and itemnumbers.

Without this patch you got the following error:
Can't call method "title" on an undefined value at /home/vagrant/kohaclone/tools/batchMod.pl line 580
Comment 9 Owen Leonard 2018-08-07 13:52:33 UTC
Created attachment 77528 [details] [review]
Bug 21141: Handle non-existent itemnumbers in batch item modification/deletion

The itemnumber list passed from a file in the batch item
modification/deletion tools is not tested.
Like barcodes we should make sure they refer to a valid items in the DB.

Test plan:
- Create a file with barcodes, itemnumbers and random lines
- Use the batch item modification and deletion tools with this file
You should see a table with a list of invalid barcodes and itemnumbers.

Without this patch you got the following error:
Can't call method "title" on an undefined value at /home/vagrant/kohaclone/tools/batchMod.pl line 580

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 10 Julian Maurice 2018-08-08 09:57:52 UTC
Created attachment 77554 [details] [review]
Bug 21141: Handle non-existent itemnumbers in batch item modification/deletion

The itemnumber list passed from a file in the batch item
modification/deletion tools is not tested.
Like barcodes we should make sure they refer to a valid items in the DB.

Test plan:
- Create a file with barcodes, itemnumbers and random lines
- Use the batch item modification and deletion tools with this file
You should see a table with a list of invalid barcodes and itemnumbers.

Without this patch you got the following error:
Can't call method "title" on an undefined value at
/home/vagrant/kohaclone/tools/batchMod.pl line 580

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Comment 11 Nick Clemens 2018-08-09 12:38:20 UTC
Awesome work all!

Pushed to master for 18.11
Comment 12 Martin Renvoize 2018-08-10 07:42:54 UTC
Pushed to 18.05.x for 18.05.03