Bugzilla – Attachment 78434 Details for
Bug 16219
Runreport.pl should allow SQL parameters to be passed on the command line
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16219: Add 'params' parameter to runreport.pl
Bug-16219-Add-params-parameter-to-runreportpl.patch (text/plain), 2.70 KB, created by
Nick Clemens (kidclamp)
on 2018-09-05 11:21:20 UTC
(
hide
)
Description:
Bug 16219: Add 'params' parameter to runreport.pl
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-09-05 11:21:20 UTC
Size:
2.70 KB
patch
obsolete
>From 488b256c46fe5d18d13b6d0fcb21fb5cfdc05f76 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 5 Sep 2018 11:15:01 +0000 >Subject: [PATCH] Bug 16219: Add 'params' parameter to runreport.pl > >To test: > 1 - Apply patch > 2 - Write a report that takes no variables > 3 - Run this using runreport.pl > perl misc/cronjobs/runreport.pl 1 > 4 - Confirm results as expected > 5 - Write a report that takes one or more variables > 6 - Run using runreport.pl, but pass no params > 7 - You should get a SQL error > 8 - Now run passing the correct number of params > perl misc/cronjobs/runreport.pl --param first --param=2nd 2 > 9 - Verify results as expected >10 - call runreport with no parameters > perl misc/cronjobs/runreport.pl >11 - Verify documentation is correct and helpful >--- > misc/cronjobs/runreport.pl | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > >diff --git a/misc/cronjobs/runreport.pl b/misc/cronjobs/runreport.pl >index b7fc9f8..45e7bee 100755 >--- a/misc/cronjobs/runreport.pl >+++ b/misc/cronjobs/runreport.pl >@@ -66,6 +66,7 @@ runreport.pl [ -h | -m ] [ -v ] reportID [ reportID ... ] > --to=s e-mail address to send report to > --from=s e-mail address to send report from > --subject=s subject for the e-mail >+ --params=s parameters for the report > --store-results store the result of the report > --csv-header add column names as first line of csv output > >@@ -121,6 +122,10 @@ E-mail address to send report from. Defaults to KohaAdminEmailAddress. > > Subject for the e-mail message. Defaults to "Koha Saved Report" > >+=item B<--params> >+ >+Repeatable, should provide one param per param requested for the report >+ > =item B<--store-results> > > Store the result of the report into the saved_reports DB table. >@@ -174,6 +179,7 @@ my $format = "text"; > my $to = ""; > my $from = ""; > my $subject = ""; >+my @params = (); > my $separator = ','; > my $quote = '"'; > my $store_results = 0; >@@ -191,6 +197,7 @@ GetOptions( > 'to=s' => \$to, > 'from=s' => \$from, > 'subject=s' => \$subject, >+ 'param=s' => \@params, > 'email' => \$email, > 'a|attachment' => \$attachment, > 'username:s' => \$username, >@@ -253,7 +260,11 @@ foreach my $report_id (@ARGV) { > $subject = 'Koha Saved Report'; > } > } >- my ($sth) = execute_query( $sql, undef, undef, undef, $report_id ); >+ >+ # convert SQL parameters to placeholders >+ $sql =~ s/(<<.*?>>)/\?/g; >+ >+ my ($sth) = execute_query( $sql, undef, undef, \@params, $report_id ); > my $count = scalar($sth->rows); > unless ($count) { > print "NO OUTPUT: 0 results from execute_query\n"; >-- >2.1.4
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 16219
:
78434
|
90363
|
91668
|
92113
|
92114
|
92115