[freeside-commits] branch FREESIDE_3_BRANCH updated. 3120e258a9a859bba3b64e493cf6d922d8b49e4c

Ivan Kohler ivan at freeside.biz
Tue Feb 20 14:18:02 PST 2018


The branch, FREESIDE_3_BRANCH has been updated
       via  3120e258a9a859bba3b64e493cf6d922d8b49e4c (commit)
       via  ded9ea12b53d20754bbf07473dc3ec9022adae51 (commit)
       via  42a331a983117cebf7e31ff0ba02ac860bd19107 (commit)
      from  906379279f9c1de0254d58313e97435aed2329e1 (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 3120e258a9a859bba3b64e493cf6d922d8b49e4c
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Feb 20 14:18:01 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 c9a216c3a..b8ba99705 100644
--- a/httemplate/misc/email-customers.html
+++ b/httemplate/misc/email-customers.html
@@ -230,6 +230,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 62e08252b..8eeb0bb1c 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, at fields_pkg, at blank_pkg);

commit ded9ea12b53d20754bbf07473dc3ec9022adae51
Merge: 42a331a98 906379279
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Feb 20 14:17:51 2018 -0800

    Merge branch 'FREESIDE_3_BRANCH' of git.freeside.biz:/home/git/freeside into FREESIDE_3_BRANCH


commit 42a331a983117cebf7e31ff0ba02ac860bd19107
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Jan 22 17:18:45 2018 -0800

    2018

diff --git a/httemplate/docs/about.html b/httemplate/docs/about.html
index a33207424..12234b1b2 100644
--- a/httemplate/docs/about.html
+++ b/httemplate/docs/about.html
@@ -28,7 +28,7 @@
 % } else {
   <FONT SIZE="-1">
 % }
-© 2017 Freeside Internet Services, Inc.<BR>
+© 2018 Freeside Internet Services, Inc.<BR>
 All rights reserved.<BR>
 Licensed under the terms of the<BR>
 GNU <b>Affero</b> General Public License.<BR>
@@ -56,7 +56,7 @@ GNU <b>Affero</b> General Public License.<BR>
 
 % unless ( $agentnum ) {
   <CENTER>
-  <FONT SIZE="-3">"All the years combine; they melt into a dream" - R. Hunter</FONT>
+  <FONT SIZE="-3">"No one's noticed, but the band's all packed and gone / Was it ever here at all?" - J. P. Barlow</FONT>
   </CENTER>
 % }
 

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

Summary of changes:
 httemplate/docs/about.html                  |  4 ++--
 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 ++++++-
 10 files changed, 67 insertions(+), 19 deletions(-)




More information about the freeside-commits mailing list