summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2018-02-20 14:17:58 -0800
committerIvan Kohler <ivan@freeside.biz>2018-02-20 14:17:58 -0800
commit70203e3be5de0331ba031d94972c274183c595d2 (patch)
tree74f6e07207800f136620b145f0af61bff488e970
parentf2412b41b222b6021df4066ae7f31010aea7e659 (diff)
fix broadband reporting with giant query URLs (large numbers of package defs, etc.), RT#76765
-rw-r--r--httemplate/elements/create_uri_query23
-rw-r--r--httemplate/elements/email-link.html13
-rw-r--r--httemplate/elements/handle_uri_query12
-rw-r--r--httemplate/misc/email-customers.html2
-rw-r--r--httemplate/search/elements/search-html.html19
-rw-r--r--httemplate/search/elements/search.html2
-rwxr-xr-xhttemplate/search/report_svc_broadband.html2
-rwxr-xr-xhttemplate/search/svc_broadband-map.html2
-rwxr-xr-xhttemplate/search/svc_broadband.cgi7
9 files changed, 65 insertions, 17 deletions
diff --git a/httemplate/elements/create_uri_query b/httemplate/elements/create_uri_query
index ce6249e0e..4d360b255 100644
--- a/httemplate/elements/create_uri_query
+++ b/httemplate/elements/create_uri_query
@@ -1,3 +1,24 @@
+<%doc>
+
+Instead of:
+
+ my $link = $self_url. '?'. $cgi->query_string;
+
+which will fail when the query string exceeds ~2k (browser-dependent)
+
+
+Usage:
+
+ my $query = $m->scomp('/elements/create_uri_query');
+ my $link = $self_url. '?'. $query;
+
+You can also pass an optional 'secure'=>1 parameter to force handling as
+session data, even for short query strings.
+
+
+See also handle_uri_query which needs to be used by the target page.
+
+</%doc>
<% $query %>\
<%init>
@@ -14,7 +35,7 @@ if ( $opt{secure} ) {
}
-my $query = $cgi->query_string;
+my $query = $opt{query} || $cgi->query_string;
if ( length($query) > 1920 || $opt{secure} ) { #stupid IE 2083 URL limit
diff --git a/httemplate/elements/email-link.html b/httemplate/elements/email-link.html
index 16935cf98..012afff1a 100644
--- a/httemplate/elements/email-link.html
+++ b/httemplate/elements/email-link.html
@@ -1,18 +1,19 @@
% if ( $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices') ) {
-<A HREF="<%$p%>misc/email-customers.html?table=<%$table%>&agent_virt_agentnum=<%$agent_virt_agentnum%>&<%$query%>"><%$label%></A>
+<A HREF="<%$p%>misc/email-customers.html?<%$query%>"><%$label%></A>
% }
<%init>
my %opt = @_;
-my $table = $opt{'table'};
-my $agent_virt_agentnum = $opt{'agent_virt_agentnum'};
my $search_hash = $opt{'search_hash'};
-die "'table' required" if !$table;
+die "'table' required" if !$opt{'table'};
die "'search_hash' required" if !$search_hash;
my $uri = new URI;
my @params = map { $_, $search_hash->{$_} } sort keys %$search_hash;
-$uri->query_form(@params);
-my $query = $uri->query;
+$uri->query_form( @params,
+ table => $opt{'table'},
+ agent_virt_agentnum => $opt{'agent_virt_agentnum'}
+ );
+my $query = $m->scomp('/elements/create_uri_query', query=>$uri->query);
my $label = ($opt{'label'} || 'Email a notice to these customers');
</%init>
diff --git a/httemplate/elements/handle_uri_query b/httemplate/elements/handle_uri_query
index 2dea96a6d..b86ef0092 100644
--- a/httemplate/elements/handle_uri_query
+++ b/httemplate/elements/handle_uri_query
@@ -1,9 +1,17 @@
+<%doc>
+
+Usage (before accessing any $cgi parameters):
+
+$m->comp('/elements/handle_uri_query');
+
+</%doc>
<%init>
-my %opt = @_;
+#my %opt = @_;
if ( $cgi->param('redirect') ) {
my $session = $cgi->param('redirect');
+ my $maxrecords = $cgi->param('maxrecords');
my $pref = $FS::CurrentUser::CurrentUser->option("redirect$session");
die "unknown redirect session $session\n" unless length($pref);
@@ -16,5 +24,7 @@ if ( $cgi->param('redirect') ) {
$cgi->param($param, $decrypted);
}
+ $cgi->param('maxrecords', $maxrecords) if $maxrecords =~ /^(\d+)$/;
+
}
</%init>
diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html
index 0ed5ef380..f7a1eb4c1 100644
--- a/httemplate/misc/email-customers.html
+++ b/httemplate/misc/email-customers.html
@@ -238,6 +238,8 @@ my $process_url = $opt{'process_url'} || 'process/email-customers.html';
my $title = $opt{'title'} || 'Send customer notices';
push( @no_search_fields, @{$opt{'no_search_fields'}} ) if $opt{'no_search_fields'};
+$m->comp('/elements/handle_uri_query');
+
my $table = $cgi->param('table') or die "'table' required";
my $agent_virt_agentnum = $cgi->param('agent_virt_agentnum') || '';
diff --git a/httemplate/search/elements/search-html.html b/httemplate/search/elements/search-html.html
index 147a2d984..29e0999c9 100644
--- a/httemplate/search/elements/search-html.html
+++ b/httemplate/search/elements/search-html.html
@@ -95,8 +95,9 @@
% {
% $cgi->delete('maxrecords');
% $cgi->param('_dummy', 1);
+% my $query = $m->scomp('/elements/create_uri_query');
- ( show <SELECT NAME="maxrecords" onChange="window.location = '<% "$self_url?". $cgi->query_string %>;maxrecords=' + this.options[this.selectedIndex].value;">
+ ( show <SELECT NAME="maxrecords" onChange="window.location = '<% "$self_url?$query" %>;maxrecords=' + this.options[this.selectedIndex].value;">
% foreach my $max ( map { $_ * $confmax } qw( 1 5 10 25 ) ) {
<OPTION VALUE="<% $max %>" <% ( $maxrecords == $max ) ? 'SELECTED' : '' %>><% $max %></OPTION>
@@ -139,18 +140,22 @@
<% $opt{'download_label'} || 'Download results:' %>
% $cgi->param('_type', "$xlsname.xls" );
- <A HREF="<% "$self_url?". $cgi->query_string %>">Spreadsheet</A>&nbsp;|&nbsp;
+% my $query = $m->scomp('/elements/create_uri_query');
+ <A HREF="<% "$self_url?$query" %>">Spreadsheet</A>&nbsp;|&nbsp;
% $cgi->param('_type', 'csv');
- <A HREF="<% "$self_url?". $cgi->query_string %>">CSV</A>&nbsp;|&nbsp;
+% my $query = $m->scomp('/elements/create_uri_query');
+ <A HREF="<% "$self_url?$query" %>">CSV</A>&nbsp;|&nbsp;
% if ( defined($opt{xml_elements}) ) {
% $cgi->param('_type', 'xml');
- <A HREF="<% "$self_url?". $cgi->query_string %>">XML</A>&nbsp;|&nbsp;
+% my $query = $m->scomp('/elements/create_uri_query');
+ <A HREF="<% "$self_url?$query" %>">XML</A>&nbsp;|&nbsp;
% }
% $cgi->param('_type', 'html-print');
- <A HREF="<% "$self_url?". $cgi->query_string %>">webpage</A>
+% my $query = $m->scomp('/elements/create_uri_query');
+ <A HREF="<% "$self_url?$query" %>">webpage</A>
%# "save search" -- for now, obey disable_download and the 'Download
%# report data' ACL, because saving a search allows the user to receive
@@ -307,8 +312,8 @@ my $self_url = $cgi->url('-path_info' => 1, '-full' =>1);
% } else {
% $cgi->param('order_by', $field);
% }
-% $label = qq(<A HREF="$self_url?). $cgi->query_string.
-% qq(">$label</A>);
+% my $query = $m->scomp('/elements/create_uri_query');
+% $label = qq(<A HREF="$self_url?$query">$label</A>);
% }
%
% $colspan = ref($header) ? $header->{colspan} : 0;
diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html
index b88bc70e4..2979eaadc 100644
--- a/httemplate/search/elements/search.html
+++ b/httemplate/search/elements/search.html
@@ -218,6 +218,8 @@ my(%opt) = @_;
my $curuser = $FS::CurrentUser::CurrentUser;
+$m->comp('/elements/handle_uri_query');
+
my $type = $cgi->param('_type') =~ /^(csv|\w*\.xls|xml|select|html(-print)?)$/
? $1 : 'html' ;
diff --git a/httemplate/search/report_svc_broadband.html b/httemplate/search/report_svc_broadband.html
index 210112bc4..45246c74a 100755
--- a/httemplate/search/report_svc_broadband.html
+++ b/httemplate/search/report_svc_broadband.html
@@ -1,6 +1,6 @@
<% include('/elements/header.html', $title ) %>
-<FORM ACTION="svc_broadband.cgi" METHOD="GET">
+<FORM ACTION="svc_broadband.cgi" METHOD="POST">
<INPUT TYPE="hidden" NAME="magic" VALUE="advanced">
<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
%# extensive false laziness with svc_acct
diff --git a/httemplate/search/svc_broadband-map.html b/httemplate/search/svc_broadband-map.html
index 95a31d352..a53907cec 100755
--- a/httemplate/search/svc_broadband-map.html
+++ b/httemplate/search/svc_broadband-map.html
@@ -10,6 +10,8 @@ die "access denied" unless
my $conf = new FS::Conf;
+$m->comp('/elements/handle_uri_query');
+
my @features; # geoJSON structure
# accept all the search logic from svc_broadband.cgi...
diff --git a/httemplate/search/svc_broadband.cgi b/httemplate/search/svc_broadband.cgi
index 80345dc91..53a0aa097 100755
--- a/httemplate/search/svc_broadband.cgi
+++ b/httemplate/search/svc_broadband.cgi
@@ -82,6 +82,8 @@ my %cust_pkg_cache;
my $conf = new FS::Conf;
+$m->comp('/elements/handle_uri_query');
+
my %search_hash;
if ( $cgi->param('magic') eq 'unlinked' ) {
%search_hash = ( 'unlinked' => 1 );
@@ -132,9 +134,12 @@ my $html_init = include('/elements/email-link.html',
'search_hash' => \%search_hash,
'table' => 'svc_broadband'
);
+
+my $query = $m->scomp('/elements/create_uri_query');
+
$html_init .= ' | ' .
'<a href="' .
- $fsurl . 'search/svc_broadband-map.html?' . $cgi->query_string .
+ $fsurl . 'search/svc_broadband-map.html?' . $query .
'">' . emt('View a map of these services') . '</a>';
my (@header_pkg,@fields_pkg,@blank_pkg);