Line 379 in 21.11. Line 415 in master now. my $item = Koha::Items->find($itemnumber); my $error = $item->safe_delete; No check whatsoever.
Created attachment 142155 [details] [review] Bug 31873: Check ->find before calling ->safe_delete When there is no item, you cannot safely delete it :) Resolve this warning: Can't call method "safe_delete" on an undefined value at /usr/share/koha/cataloguing/additem.pl line 379 (Line numbers may vary across versions.) Test plan: Open item editor. Add a new item. Add another tab with same form. Delete new item. Go back to former tab. Try to delete again. You should see an alert now on top of the form. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
NOTE: The log file did not tell me the real reproduction scenario but the test plan should be enough to catch the point.
Note that this cannot be backported without change in 21.11 due to Boolean.pm stuff. If needed, I have a patch.
Created attachment 142206 [details] [review] Bug 31873: Check ->find before calling ->safe_delete When there is no item, you cannot safely delete it :) Resolve this warning: Can't call method "safe_delete" on an undefined value at /usr/share/koha/cataloguing/additem.pl line 379 (Line numbers may vary across versions.) Test plan: Open item editor. Add a new item. Add another tab with same form. Delete new item. Go back to former tab. Try to delete again. You should see an alert now on top of the form. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: David Nind <david@davidnind.com> https://bugs.koha-community.org/show_bug.cgi?id=31783
Created attachment 143012 [details] [review] Bug 31873: Check ->find before calling ->safe_delete When there is no item, you cannot safely delete it :) Resolve this warning: Can't call method "safe_delete" on an undefined value at /usr/share/koha/cataloguing/additem.pl line 379 (Line numbers may vary across versions.) Test plan: Open item editor. Add a new item. Add another tab with same form. Delete new item. Go back to former tab. Try to delete again. You should see an alert now on top of the form. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Works as described, code is clean. Passing QA
Pushed to master for 22.11. Nice work everyone, thanks!
Backported to 22.05.x for upcoming 22.05.09
pushed to 21.11.x for 21.11.16
Reverted on 21.11.x branch, missing Koha::Result::Boolean dependency.
Not backported to 21.05.x