[freeside-commits] branch master updated. 266e0c3c894568fb06a15dfbcf4a4eb9bc6989b3

Ivan Kohler ivan at freeside.biz
Tue Feb 20 14:17:56 PST 2018


The branch, master has been updated
       via  266e0c3c894568fb06a15dfbcf4a4eb9bc6989b3 (commit)
      from  ed2d4de2ea785d30a54fb069b29f9618a40113c9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 266e0c3c894568fb06a15dfbcf4a4eb9bc6989b3
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Feb 20 14:17:55 2018 -0800

    fix broadband reporting with giant query URLs (large numbers of package defs, etc.), RT#76765

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 f52c6b36a..3f8816caa 100644
--- a/httemplate/misc/email-customers.html
+++ b/httemplate/misc/email-customers.html
@@ -302,6 +302,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> | 
+%               my $query = $m->scomp('/elements/create_uri_query');
+                <A HREF="<% "$self_url?$query" %>">Spreadsheet</A> | 
 
 %               $cgi->param('_type', 'csv'); 
-                <A HREF="<% "$self_url?". $cgi->query_string %>">CSV</A> | 
+%               my $query = $m->scomp('/elements/create_uri_query');
+                <A HREF="<% "$self_url?$query" %>">CSV</A> | 
 
 %             if ( defined($opt{xml_elements}) ) {
 %               $cgi->param('_type', 'xml'); 
-                <A HREF="<% "$self_url?". $cgi->query_string %>">XML</A> | 
+%               my $query = $m->scomp('/elements/create_uri_query');
+                <A HREF="<% "$self_url?$query" %>">XML</A> | 
 %             }
 
 %               $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 18b4c0ec5..0e8c69a51 100644
--- a/httemplate/search/elements/search.html
+++ b/httemplate/search/elements/search.html
@@ -222,6 +222,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 41f4b8dfd..65830b5d2 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, at fields_pkg, at blank_pkg);

-----------------------------------------------------------------------

Summary of changes:
 httemplate/elements/create_uri_query        | 23 ++++++++++++++++++++++-
 httemplate/elements/email-link.html         | 13 +++++++------
 httemplate/elements/handle_uri_query        | 12 +++++++++++-
 httemplate/misc/email-customers.html        |  2 ++
 httemplate/search/elements/search-html.html | 19 ++++++++++++-------
 httemplate/search/elements/search.html      |  2 ++
 httemplate/search/report_svc_broadband.html |  2 +-
 httemplate/search/svc_broadband-map.html    |  2 ++
 httemplate/search/svc_broadband.cgi         |  7 ++++++-
 9 files changed, 65 insertions(+), 17 deletions(-)




More information about the freeside-commits mailing list