From f11072d4db5881ec9a7ef790874b963cc503dbea Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 17 Apr 2018 12:48:23 +1000 Subject: [PATCH] Bug 20592 - updateitem.pl causes database errors when empty non-public item notes updated Previously, clicking "Update" next to non-public item note when the text box was empty would generate a database error. This patches adds a condition where ModItem() is only called if there are actual changes to be made to the record. _TEST PLAN_ 1) Create a bibliographic record 2) Create an item for that bib record 3) Go to /cgi-bin/koha/catalogue/moredetail.pl?biblionumber=1&itemnumber=1 4) Click "Update" next to "Non-public note" 5) Note a "DBD::mysql::st execute failed" error in your logs 6) Apply patch 7) Click "Update" next to "Non-public note" 8) Note that there is no longer an error 9) Add text to the box and click "Update" to ensure update still works --- catalogue/updateitem.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/catalogue/updateitem.pl b/catalogue/updateitem.pl index b7cbc9445c..d969ac3cdc 100755 --- a/catalogue/updateitem.pl +++ b/catalogue/updateitem.pl @@ -78,7 +78,9 @@ elsif (defined $itemnotes) { # i.e., itemnotes parameter passed from form exit; } -ModItem($item_changes, $biblionumber, $itemnumber); +if ($biblionumber && $itemnumber && %$item_changes){ + ModItem($item_changes, $biblionumber, $itemnumber); +} LostItem($itemnumber) if $itemlost; -- 2.13.6