Bugzilla – Attachment 161429 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), 4.39 KB, created by
Kyle M Hall (khall)
on 2024-01-25 15:31:22 UTC
(
hide
)
Description:
Bug 35907: Tidy execute_query
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2024-01-25 15:31:22 UTC
Size:
4.39 KB
patch
obsolete
>From a5a175a04bd03f0b45b96bf9c807b31efbe79575 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 | 47 ++++++++++++++++++++++---------------------- > 1 file changed, 24 insertions(+), 23 deletions(-) > >diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm >index 96e6f8e2c9b..481140da927 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; > } > } >@@ -611,19 +611,20 @@ sub execute_query { > > $dbh->do( 'UPDATE saved_sql SET last_run = NOW() WHERE id = ?', undef, $report_id ) if $report_id; > >- Koha::Logger->get({ prefix => 0, interface => 'reports', category => 'execute.query'})->info("Report $report_id : $sql, $offset, $limit"); >- Koha::Logger->get({ prefix => 0, interface => 'reports', category => 'execute.time.start'})->info("Report starting: $report_id"); >+ Koha::Logger->get( { prefix => 0, interface => 'reports', category => 'execute.query' } ) >+ ->info("Report $report_id : $sql, $offset, $limit"); >+ Koha::Logger->get( { prefix => 0, interface => 'reports', category => 'execute.time.start' } ) >+ ->info("Report starting: $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"); >+ Koha::Logger->get( { prefix => 0, interface => 'reports', category => 'execute.time.end' } ) >+ ->info("Report finished: $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