[Koha-bugs] [Bug 11338] wrong SQL in DelItemCheck

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Dec 4 17:12:49 CET 2013


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11338

--- Comment #1 from Fridolin SOMERS <fridolyn.somers at biblibre.com> ---
Created attachment 23303
  -->
http://bugs.koha-community.org/bugzilla3/attachment.cgi?id=23303&action=edit
Bug 11338 - wrong SQL in DelItemCheck

In C4::Items::DelItemCheck, there are two SQL queries : one to check if item is
on loan, the other if item is reserved.
Those two queries use "SELECT * FROM table", fetch the datas with "$var =
$sth->fetchrow", and use "$var" as a boolean condition.
This is not correct, SQL query should be "SELECT COUNT(*) FROM table".
Code actually works, but is dangerous.

This patch corrects the SQL queries and sets my ($var) to show that fetchrow
returns an array.

Test plan :
- Set an item A onloan
- Set an item B reserved and the reserve waiting
- Go to items cataloguing :
cgi-bin/koha/cataloguing/additem.pl?biblionumber=XXX
- Try to delete item A
=> You get an alert and item is not deleted
- Try to delete item B
=> You get an alert and item is not deleted

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list