From 81f06881a45d7647481aa8a21354a772f3daff88 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 7 Aug 2020 12:44:28 +0200 Subject: [PATCH] Bug 26165: Fix duplication of large saved reports If the combined character length of a saved report's title, notes and SQL is too long then pressing the 'duplicate' button will lead to an error: "Request-URI Too Long The requested URL's length exceeds the capacity limit for this server." Test plan: 1. Create a simple SQL report and add a lot of text into the notes field (the combined URL lenth must be >8225 characters) 2. Save the report 3. Press the duplicate the report from the saved reports page Signed-off-by: Owen Leonard Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- .../prog/en/includes/reports-toolbar.inc | 2 +- .../modules/reports/guided_reports_start.tt | 2 +- reports/guided_reports.pl | 33 ++++++++++++------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc index fd7ce29ce9..305de93f34 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc @@ -23,7 +23,7 @@ [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt index e704e19493..a7a52b7c5b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt @@ -332,7 +332,7 @@
  • Show
  • [% IF ( CAN_user_reports_create_reports ) %]
  • Edit
  • -
  • Duplicate
  • +
  • Duplicate
  • [% END %] [% IF (Koha.Preference('Mana') == 1) %]
  • diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index fa2817f1c7..f52a6df432 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -55,7 +55,8 @@ my $usecache = Koha::Caches->get_instance->memcached_cache; my $phase = $input->param('phase') // ''; my $flagsrequired; -if ( ( $phase eq 'Build new' ) || ( $phase eq 'Create report from SQL' ) || ( $phase eq 'Edit SQL' ) ){ +if ( ( $phase eq 'Build new' ) || ( $phase eq 'Create report from SQL' ) || ( $phase eq 'Edit SQL' ) + || ( $phase eq 'Build new from existing' ) ) { $flagsrequired = 'create_reports'; } elsif ( $phase eq 'Use saved' ) { @@ -973,25 +974,35 @@ elsif ($phase eq 'Export'){ ); } -elsif ( $phase eq 'Create report from SQL' ) { +elsif ( $phase eq 'Create report from SQL' || $phase eq 'Create report from existing' ) { - my ($group, $subgroup); - # allow the user to paste in sql + my ($group, $subgroup, $sql, $reportname, $notes); if ( $input->param('sql') ) { - $group = $input->param('report_group'); - $subgroup = $input->param('report_subgroup'); - $template->param( - 'sql' => scalar $input->param('sql') // '', - 'reportname' => scalar $input->param('reportname') // '', - 'notes' => scalar $input->param('notes') // '', - ); + $group = $input->param('report_group'); + $subgroup = $input->param('report_subgroup'); + $sql = $input->param('sql') // ''; + $reportname = $input->param('reportname') // ''; + $notes = $input->param('notes') // ''; + } + elsif ( my $report_id = $input->param('report_id') ) { + my $report = Koha::Reports->find($report_id); + $group = $report->report_group; + $subgroup = $report->report_subgroup; + $sql = $report->savedsql // ''; + $reportname = $report->report_name // ''; + $notes = $report->notes // ''; } + $template->param( + sql => $sql, + reportname => $reportname, + notes => $notes, 'create' => 1, 'groups_with_subgroups' => groups_with_subgroups($group, $subgroup), 'public' => '0', 'cache_expiry' => 300, 'usecache' => $usecache, + ); } -- 2.39.5