Bugzilla – Attachment 23792 Details for
Bug 11338
items that are captured for holds can be deleted without warning
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 11338 - wrong SQL in DelItemCheck
PASSED-QA-Bug-11338---wrong-SQL-in-DelItemCheck.patch (text/plain), 2.50 KB, created by
Katrin Fischer
on 2013-12-23 19:17:47 UTC
(
hide
)
Description:
[PASSED QA] Bug 11338 - wrong SQL in DelItemCheck
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2013-12-23 19:17:47 UTC
Size:
2.50 KB
patch
obsolete
>From f2fd66f4ed6601c7be204a65b91079f7aff40652 Mon Sep 17 00:00:00 2001 >From: Fridolyn SOMERS <fridolyn.somers@biblibre.com> >Date: Wed, 4 Dec 2013 17:05:32 +0100 >Subject: [PATCH] [PASSED QA] 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 > >Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> > >Works, and has the added bonus of being a tiny bit faster. > >Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> >Passes t, xt and QA script tests. >Also tried deleting via batch delete - correct warnings are displayed. >--- > C4/Items.pm | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index 4c1a4ad..af61346 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -2253,11 +2253,14 @@ sub DelItemCheck { > > > # check that there is no issue on this item before deletion. >- my $sth=$dbh->prepare("select * from issues i where i.itemnumber=?"); >+ my $sth = $dbh->prepare(q{ >+ SELECT COUNT(*) FROM issues >+ WHERE itemnumber = ? >+ }); > $sth->execute($itemnumber); >+ my ($onloan) = $sth->fetchrow; > > my $item = GetItem($itemnumber); >- my $onloan=$sth->fetchrow; > > if ($onloan){ > $error = "book_on_loan" >@@ -2270,9 +2273,13 @@ sub DelItemCheck { > } > else{ > # check it doesnt have a waiting reserve >- $sth=$dbh->prepare("SELECT * FROM reserves WHERE (found = 'W' or found = 'T') AND itemnumber = ?"); >+ $sth = $dbh->prepare(q{ >+ SELECT COUNT(*) FROM reserves >+ WHERE (found = 'W' OR found = 'T') >+ AND itemnumber = ? >+ }); > $sth->execute($itemnumber); >- my $reserve=$sth->fetchrow; >+ my ($reserve) = $sth->fetchrow; > if ($reserve){ > $error = "book_reserved"; > } elsif ($countanalytics > 0){ >-- >1.8.3.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11338
:
23303
|
23761
| 23792