From b8812f4eb7c4dc0e43b7bdefd0e06516221ae0c4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 25 Nov 2014 15:04:25 +0100 Subject: [PATCH] Bug 13332: Fix conflict between 5304 and 10860 These 2 bugs are in conflict. The first one always join the issue table, the second one join on this table too if the OnSiteCheckouts pref is enable. So DBI raises an error if the pref is enabled (2 joins on the same table). This patch removes the conditional join. Test plan: Go on a detail record page with items and verify that items are list and that the error no more appears in the log file. Signed-off-by: Tomas Cohen Arazi Reproduced the problem, the patch fixes it, no noticeable regression found. --- C4/Items.pm | 5 +---- t/db_dependent/Items.t | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index ab2456b..e63ef1b 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1298,6 +1298,7 @@ sub GetItemsInfo { items.notforloan as itemnotforloan, issues.borrowernumber, issues.date_due as datedue, + issues.onsite_checkout, borrowers.cardnumber, borrowers.surname, borrowers.firstname, @@ -1311,8 +1312,6 @@ sub GetItemsInfo { holding.opac_info as holding_branch_opac_info, home.opac_info as home_branch_opac_info "; - $query .= ", issues.onsite_checkout" - if C4::Context->preference("OnSiteCheckouts"); $query .= " FROM items LEFT JOIN branches AS holding ON items.holdingbranch = holding.branchcode @@ -1325,8 +1324,6 @@ sub GetItemsInfo { LEFT JOIN serial USING (serialid) LEFT JOIN itemtypes ON itemtypes.itemtype = " . (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype'); - $query .= " LEFT JOIN issues ON issues.itemnumber = items.itemnumber" - if C4::Context->preference("OnSiteCheckouts"); $query .= " WHERE items.biblionumber = ? ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ; my $sth = $dbh->prepare($query); $sth->execute($biblionumber); diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index 243ab2d..d94b7b7 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -157,7 +157,7 @@ subtest 'GetHiddenItemnumbers tests' => sub { subtest 'GetItemsInfo tests' => sub { - plan tests => 3; + plan tests => 4; # Start transaction $dbh->{AutoCommit} = 0; @@ -186,6 +186,8 @@ subtest 'GetItemsInfo tests' => sub { 'GetItemsInfo returns the correct home branch OPAC info notice' ); is( $results[0]->{ holding_branch_opac_info }, "holdingbranch OPAC info", 'GetItemsInfo returns the correct holding branch OPAC info notice' ); + is( exists( $results[0]->{ onsite_checkout } ), 1, + 'GetItemsInfo returns a onsite_checkout key' ); $dbh->rollback; }; -- 1.9.1