Bug 29243

Summary: PrepareItemrecordDisplay should not be called with empty string in defaultvalues
Product: Koha Reporter: Nick Clemens <nick>
Component: Architecture, internals, and plumbingAssignee: Nick Clemens <nick>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: fridolin.somers, kyle, martin.renvoize
Version: master   
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:
21.11.00,21.05.05
Bug Depends on: 27545    
Bug Blocks:    
Attachments: Bug 29243: Correct call when adding items from staged records
Bug 29243: Correct call when adding items from staged records
Bug 29243: Correct call when adding items from staged records

Description Nick Clemens 2021-10-14 11:21:33 UTC
Bug 27545 expanded the use of NewItemsDefaultLocation, however, it checks for $defaultvalues undefined.

There are several calls that pass '' (empty string) for default values.

It is expected to be a hashref, so we should pass undef if we don't have defaults.

Otherwise, we get an error when NewItemsDefaultLocation is set:
Can't use string ("") as a HASH ref while "strict refs" in use at /usr/share/koha/lib/C4/Items.pm line 1605.
Comment 1 Nick Clemens 2021-10-14 11:34:46 UTC
Created attachment 126271 [details] [review]
Bug 29243: Correct call when adding items from staged records

To test:
1 - Populate system preference  NewItemsDefaultLocation
2 - Stage a file of marc records
3 - Create an acquisitions basket with 'AcqCreateItems' set to 'ordering'
4 - Attempt to add to basket from your staged file
5 - You get a 500 error, and in the logs:
    Can't use string ("") as a HASH ref while "strict refs" in use at /usr/share/koha/lib/C4/Items.pm line 1605.
6 - Apply patch
7 - Repeat #4
8 - Success!
Comment 2 Andrew Fuerste-Henry 2021-10-14 15:49:08 UTC
Created attachment 126297 [details] [review]
Bug 29243: Correct call when adding items from staged records

To test:
1 - Populate system preference  NewItemsDefaultLocation
2 - Stage a file of marc records
3 - Create an acquisitions basket with 'AcqCreateItems' set to 'ordering'
4 - Attempt to add to basket from your staged file
5 - You get a 500 error, and in the logs:
    Can't use string ("") as a HASH ref while "strict refs" in use at /usr/share/koha/lib/C4/Items.pm line 1605.
6 - Apply patch
7 - Repeat #4
8 - Success!

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Comment 3 Martin Renvoize 2021-10-15 08:35:04 UTC
Created attachment 126311 [details] [review]
Bug 29243: Correct call when adding items from staged records

To test:
1 - Populate system preference  NewItemsDefaultLocation
2 - Stage a file of marc records
3 - Create an acquisitions basket with 'AcqCreateItems' set to 'ordering'
4 - Attempt to add to basket from your staged file
5 - You get a 500 error, and in the logs:
    Can't use string ("") as a HASH ref while "strict refs" in use at /usr/share/koha/lib/C4/Items.pm line 1605.
6 - Apply patch
7 - Repeat #4
8 - Success!

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2021-10-15 08:35:34 UTC
Clear patch, works as expected. QA Scripts are happy.

Passing QA
Comment 5 Jonathan Druart 2021-10-18 09:34:20 UTC
Pushed to master for 21.11, thanks to everybody involved!
Comment 6 Kyle M Hall 2021-10-22 15:07:10 UTC
Pushed to 21.05.x for 21.05.05
Comment 7 Fridolin Somers 2021-10-23 01:47:18 UTC
Depends on Bug 27545 not in 20.11.x