From c324654f8a691bff326b6951fa13575718581efc Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 9 Mar 2018 10:51:53 -0300 Subject: [PATCH] Bug 19943: Gentle error handling for bookcount.pl This patch tests the required parameters and redirects with a 400 HTTP code if parameters are invalid. It also removes the need for the passed biblioitemnumber which is not used at all. A (now) useless sub is removed too. Signed-off-by: Tomas Cohen Arazi --- circ/bookcount.pl | 22 ++++++++-------------- .../prog/en/modules/catalogue/moredetail.tt | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/circ/bookcount.pl b/circ/bookcount.pl index 3d20aac540..438d85126e 100755 --- a/circ/bookcount.pl +++ b/circ/bookcount.pl @@ -34,12 +34,14 @@ use Koha::Libraries; my $input = new CGI; my $itm = $input->param('itm'); -my $bi = $input->param('bi'); my $biblionumber = $input->param('biblionumber'); -my $idata = itemdatanum($itm); my $biblio = Koha::Biblios->find( $biblionumber ); -die "No valid biblionumber passed" unless $biblio; # FIXME A bit rude! +my $item = Koha::Items->find( $itm ); + +if ( !defined $biblio or !defined $item ) { + print $input->redirect("/cgi-bin/koha/errors/400.pl"); +} my $lastmove = lastmove($itm); @@ -76,10 +78,9 @@ $template->param( biblionumber => $biblionumber, title => $biblio->title, author => $biblio->author, - barcode => $idata->{'barcode'}, - biblioitemnumber => $bi, - homebranch => $idata->{homebranch}, - holdingbranch => $idata->{holdingbranch}, + barcode => $item->barcode, + homebranch => $item->homebranch, + holdingbranch => $item->holdingbranch, lastdate => $lastdate ? $lastdate : 0, count => $count, libraries => $libraries, @@ -88,13 +89,6 @@ $template->param( output_html_with_http_headers $input, $cookie, $template->output; exit; -sub itemdatanum { - my ($itemnumber) = @_; - my $sth = C4::Context->dbh->prepare("SELECT * FROM items WHERE itemnumber=?"); - $sth->execute($itemnumber); - return $sth->fetchrow_hashref; -} - sub lastmove { my ($itemnumber) = @_; my $dbh = C4::Context->dbh; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt index 3fb7856d59..ad8aefbb9a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt @@ -223,7 +223,7 @@ [% END %] -
  • Total checkouts:[% IF ( ITEM_DAT.issues ) %][% ITEM_DAT.issues %][% ELSE %]0[% END %] (View item's checkout history)
  • +
  • Total checkouts:[% IF ( ITEM_DAT.issues ) %][% ITEM_DAT.issues %][% ELSE %]0[% END %] (View item's checkout history)
  • Last seen:[% IF ( ITEM_DAT.datelastseen ) %][% ITEM_DAT.datelastseen | $KohaDates %] [%END %] 
  • Last borrowed:[% IF (ITEM_DAT.datelastborrowed ) %][% ITEM_DAT.datelastborrowed | $KohaDates %][% END %] 
  • -- 2.16.2