Bugzilla – Attachment 161453 Details for
Bug 35907
Add ability to log all custom report runs with or without query
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35907: Tidy execute_query
Bug-35907-Tidy-executequery.patch (text/plain), 3.66 KB, created by
Kyle M Hall (khall)
on 2024-01-25 17:06:40 UTC
(
hide
)
Description:
Bug 35907: Tidy execute_query
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2024-01-25 17:06:40 UTC
Size:
3.66 KB
patch
obsolete
>From 20ed220ec5600a295748eb185c7614a85266d083 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 25 Jan 2024 10:27:11 -0500 >Subject: [PATCH] Bug 35907: Tidy execute_query > >--- > C4/Reports/Guided.pm | 38 ++++++++++++++++++-------------------- > 1 file changed, 18 insertions(+), 20 deletions(-) > >diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm >index d294ace736e..5edec6afdd5 100644 >--- a/C4/Reports/Guided.pm >+++ b/C4/Reports/Guided.pm >@@ -557,11 +557,10 @@ and that the number placeholders matches the number of parameters. > =cut > > sub execute_query { >- > my $params = shift; > my $sql = $params->{sql}; > my $offset = $params->{offset} || 0; >- my $limit = $params->{limit} || C4::Context->config('report_results_limit') || 999999; >+ my $limit = $params->{limit} || C4::Context->config('report_results_limit') || 999999; > my $sql_params = defined $params->{sql_params} ? $params->{sql_params} : []; > my $report_id = $params->{report_id}; > >@@ -573,35 +572,36 @@ sub execute_query { > > Koha::Logger->get->debug("Report - execute_query($sql, $offset, $limit)"); > >- my ( $is_sql_valid, $errors ) = Koha::Report->new({ savedsql => $sql })->is_sql_valid; >- return (undef, @{$errors}[0]) unless $is_sql_valid; >+ my ( $is_sql_valid, $errors ) = Koha::Report->new( { savedsql => $sql } )->is_sql_valid; >+ return ( undef, @{$errors}[0] ) unless $is_sql_valid; > >- foreach my $sql_param ( @$sql_params ){ >- if ( $sql_param =~ m/\n/ ){ >+ foreach my $sql_param (@$sql_params) { >+ if ( $sql_param =~ m/\n/ ) { > my @list = split /\n/, $sql_param; > my @quoted_list; >- foreach my $item ( @list ){ >+ foreach my $item (@list) { > $item =~ s/\r//; >- push @quoted_list, C4::Context->dbh->quote($item); >+ push @quoted_list, C4::Context->dbh->quote($item); > } >- $sql_param = "(".join(",",@quoted_list).")"; >+ $sql_param = "(" . join( ",", @quoted_list ) . ")"; > } > } > >- my ($useroffset, $userlimit); >+ my ( $useroffset, $userlimit ); > > # Grab offset/limit from user supplied LIMIT and drop the LIMIT so we can control pagination >- ($sql, $useroffset, $userlimit) = strip_limit($sql); >+ ( $sql, $useroffset, $userlimit ) = strip_limit($sql); > > Koha::Logger->get->debug( > sprintf "User has supplied (OFFSET,) LIMIT = %s, %s", >- $useroffset, ( defined($userlimit) ? $userlimit : 'UNDEF' ) ); >+ $useroffset, ( defined($userlimit) ? $userlimit : 'UNDEF' ) >+ ); > > $offset += $useroffset; >- if (defined($userlimit)) { >- if ($offset + $limit > $userlimit ) { >+ if ( defined($userlimit) ) { >+ if ( $offset + $limit > $userlimit ) { > $limit = $userlimit - $offset; >- } elsif ( ! $offset && $limit < $userlimit ) { >+ } elsif ( !$offset && $limit < $userlimit ) { > $limit = $userlimit; > } > } >@@ -617,16 +617,14 @@ sub execute_query { > ->info("Report starting: $report_id") if $report_id; > > my $sth = $dbh->prepare($sql); >- eval { >- $sth->execute(@$sql_params, $offset, $limit); >- }; >+ eval { $sth->execute( @$sql_params, $offset, $limit ); }; > warn $@ if $@; > > Koha::Logger->get( { prefix => 0, interface => 'reports', category => 'execute.time.end' } ) > ->info("Report finished: $report_id") if $report_id; > >- return ( $sth, { queryerr => $sth->errstr } ) if ($sth->err); >- return ( $sth ); >+ return ( $sth, { queryerr => $sth->errstr } ) if ( $sth->err ); >+ return ($sth); > } > > =head2 save_report($sql,$name,$type,$notes) >-- >2.30.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 35907
:
161427
|
161429
|
161452
|
161453
|
161458
|
161459
|
161806
|
161807
|
166501
|
166502