Created attachment 117138 [details] [review] Bug 27745: prevent warning for uninitialized value as a hash key When you edit and save items in current code with an empty "c - Shelving location" field, it gets stored into the database as "NULL", which is allowed in the database, and the field is not "required", so this seems expected. But when the search page book's card is rendered, it gets value by location key ($shelflocations->{ $item->{location} }) which gives undef warning. Solved by screening undef value with the empty string. To reproduce: 1) Edit the book or create new one with an empty shelving location. 2) Use the search feature to have that book in the searched list. 3) Check plack-intranet-error.log to find "Use of uninitialized value in hash element" error. 4) Apply the patch. 5) Repeat the search and check the logs again to ensure that error didn't appear again.
Hi, Missing in test plan: 1.a) loan the item. Moreover elsewhere there's stuff like: $other_items->{$key}->{location} = $shelflocations->{ $item->{location} } if $item->{location}; Shouldn't it use the same here too ?
Hey, I don't think you need to loan the item specifically to get this error, I tested it again and I got the error even when item wasn't leaned. Unless I misunderstood what you meant, in that case please correct me. I agree, thanks for pointing that out. It makes more sense to change it to: > $other_items->{$key}->{location} = $shelflocations->{ $item->{location} } if $item->{location};
Created attachment 117554 [details] [review] Bug 27745: prevent warning for uninitialized value as a hash key When you edit and save items with an empty "c - Shelving location" field, it gets stored into the database as "NULL", which is allowed in the database, and the field is not "required", so this seems expected. But when the search page is rendered, it gets value by location key ($shelflocations->{ $item->{location} }) which gives undef warning. Solved by checking if $item->{location} is perl true. To reproduce: 1) Edit the book or create new one with an empty shelving location. 2) Use the search feature to have that book in the searched list. 3) Check plack-intranet-error.log to find "Use of uninitialized value in hash element" error. 4) Apply the patch. 5) Repeat the search and check the logs again to ensure that error didn't appear again.
Created attachment 117614 [details] [review] Bug 27745: prevent warning for uninitialized value as a hash key When you edit and save items with an empty "c - Shelving location" field, it gets stored into the database as "NULL", which is allowed in the database, and the field is not "required", so this seems expected. But when the search page is rendered, it gets value by location key ($shelflocations->{ $item->{location} }) which gives undef warning. Solved by checking if $item->{location} is perl true. To reproduce: 1) Edit the book or create new one with an empty shelving location. 2) Use the search feature to have that book in the searched list. 3) Check plack-intranet-error.log to find "Use of uninitialized value in hash element" error. 4) Apply the patch. 5) Repeat the search and check the logs again to ensure that error didn't appear again. Signed-off-by: Didier Gautheron <didier.gautheron@biblibre.com>
Created attachment 117783 [details] [review] Bug 27745: prevent warning for uninitialized value as a hash key When you edit and save items with an empty "c - Shelving location" field, it gets stored into the database as "NULL", which is allowed in the database, and the field is not "required", so this seems expected. But when the search page is rendered, it gets value by location key ($shelflocations->{ $item->{location} }) which gives undef warning. Solved by checking if $item->{location} is perl true. To reproduce: 1) Edit the book or create new one with an empty shelving location. 2) Use the search feature to have that book in the searched list. 3) Check plack-intranet-error.log to find "Use of uninitialized value in hash element" error. 4) Apply the patch. 5) Repeat the search and check the logs again to ensure that error didn't appear again. Signed-off-by: Didier Gautheron <didier.gautheron@biblibre.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Pushed to master for 21.05, thanks to everybody involved!
Pushed to 20.11.x for 20.11.04
Pushed to 20.05.x for 20.05.10
Not backported to oldoldstable (19.11.x). Feel free to ask if it's needed.