Bugzilla – Attachment 145637 Details for
Bug 32511
Circulation statistics result Error 500 where select Collection, Shelving location, Home library or Holding library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32511: Circulation statistics result Error 500 where select Collection, Shelving location, Home library or Holding library
Bug-32511-Circulation-statistics-result-Error-500-.patch (text/plain), 2.50 KB, created by
Hammat wele
on 2023-01-24 21:49:05 UTC
(
hide
)
Description:
Bug 32511: Circulation statistics result Error 500 where select Collection, Shelving location, Home library or Holding library
Filename:
MIME Type:
Creator:
Hammat wele
Created:
2023-01-24 21:49:05 UTC
Size:
2.50 KB
patch
obsolete
>From 9dd29f8f5cf14a2842956b3e3d9d62e7c16d2a78 Mon Sep 17 00:00:00 2001 >From: Hammat Wele <hammat.wele@inlibro.com> >Date: Tue, 24 Jan 2023 21:47:59 +0000 >Subject: [PATCH] Bug 32511: Circulation statistics result Error 500 where > select Collection, Shelving location, Home library or Holding library > >Circulation statistics show error 500 when the tables 'items' and 'deleteditems' do not have the same number of columns. The error 'The used SELECT statements have a different number of columns' is shown in apache log. > >This patch resolvs the problem by selecting the common columns before execute the 'UNION' operator. > >To Test > > 1. In Staff interface, click on Reports module > 2. Click on Circulation > 3. Fill the form > Period: Click on 'Row' and Select a date interval > 4. Click on 'Submit' > --> Koha gives a 500 error message > 5. Apply the patch > 6. Repeat step 1,2,3,4 > --> There's no more error >--- > reports/issues_stats.pl | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > >diff --git a/reports/issues_stats.pl b/reports/issues_stats.pl >index 52e904ed5f..925346dba5 100755 >--- a/reports/issues_stats.pl >+++ b/reports/issues_stats.pl >@@ -30,6 +30,7 @@ use C4::Reports qw( GetDelimiterChoices ); > use Koha::AuthorisedValues; > use Koha::ItemTypes; > use Koha::Patron::Attribute::Types; >+use Array::Utils qw( intersect ); > > =head1 NAME > >@@ -495,7 +496,21 @@ sub calculate { > $strcalc .= " LEFT JOIN borrower_attributes AS attribute_$_ ON (statistics.borrowernumber = attribute_$_.borrowernumber AND attribute_$_.code = '$_') "; > } > } >- $strcalc .= "LEFT JOIN (SELECT * FROM items UNION SELECT * FROM deleteditems) items ON statistics.itemnumber=items.itemnumber " >+ my @listfield_items; >+ my @listfield_deleteditems; >+ my $colunmlist; >+ my $sth3 = $dbh->prepare("SHOW COLUMNS FROM items;"); >+ $sth3->execute; >+ while ( (my $field) = $sth3->fetchrow_array ) { >+ push @listfield_items, $field; >+ } >+ $sth3 = $dbh->prepare("SHOW COLUMNS FROM deleteditems;"); >+ $sth3->execute; >+ while ( (my $field) = $sth3->fetchrow_array ) { >+ push @listfield_deleteditems, $field; >+ } >+ $colunmlist = join(",",intersect(@listfield_items, @listfield_deleteditems)); >+ $strcalc .= "LEFT JOIN (SELECT $colunmlist FROM items UNION SELECT $colunmlist FROM deleteditems) items ON statistics.itemnumber=items.itemnumber " > if ( $linefield =~ /^items\./ > or $colfield =~ /^items\./ > or $process == 5 >-- >2.34.1
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 32511
:
144755
|
144756
|
144757
|
144758
|
145637
|
145661
|
145662
|
145694