diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm index 8407311a5..fb864a06d 100644 --- a/Bugzilla/CGI.pm +++ b/Bugzilla/CGI.pm @@ -117,7 +117,6 @@ sub parse_params { sub canonicalise_query { my ($self, @exclude) = @_; - $self->convert_old_params(); # Reconstruct the URL by concatenating the sorted param=value pairs my @parameters; foreach my $key (sort($self->param())) { @@ -142,17 +141,6 @@ sub canonicalise_query { return join("&", @parameters); } -sub convert_old_params { - my $self = shift; - - # bugidtype is now bug_id_type. - if ($self->param('bugidtype')) { - my $value = $self->param('bugidtype') eq 'exclude' ? 'nowords' : 'anyexact'; - $self->param('bug_id_type', $value); - $self->delete('bugidtype'); - } -} - sub clean_search_url { my $self = shift; # Delete any empty URL parameter. diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 0d44cb0af..a5c9ccd6a 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -945,10 +945,7 @@ sub init my $self = shift; my @fields = @{ $self->{fields} || [] }; - my $params = $self->{params}; - $params->convert_old_params(); - # Copy hash and throw away tied reference returned by CGI::Vars() - my $H = { %{ $params->Vars } }; + my $H = $self->{params}; # $self->{user} = User under which the search will be ran # Bugzilla->user = Just current user @@ -1042,6 +1039,11 @@ sub init delete $legal_fields->{$_} for keys %{TIMETRACKING_FIELDS()}; } + if (exists $H->{bugidtype}) + { + $H->{bug_id_type} = delete $H->{bugidtype} eq 'exclude' ? 'nowords' : 'anyexact'; + } + # Extract and _type from parameters foreach (keys %$H) { @@ -2957,9 +2959,8 @@ sub _in_search_results { my $self = shift; my $query = LookupNamedQuery(trim($self->{value})); - my $queryparams = new Bugzilla::CGI($query); my $search = new Bugzilla::Search( - params => $queryparams, + params => http_decode_query($query), fields => [ "bugs.bug_id" ], user => Bugzilla->user, ); diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index baa3b3c23..03fca1cfd 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -268,7 +268,7 @@ sub url_quote_noslash return $toencode; } -# http_build_query($hashref) like PHP's one +# http_build_query($hashref), like PHP's one sub http_build_query($) { my ($query) = @_; @@ -276,7 +276,7 @@ sub http_build_query($) url_quote($_).'='.(ref $query->{$_} ? join('&'.url_quote($_).'=', map { url_quote($_) } @{$query->{$_}}) : url_quote($query->{$_})) - } keys %$query); + } sort keys %$query); } # Decode query string to a hashref diff --git a/buglist.cgi b/buglist.cgi index 73a43836a..b91509a29 100755 --- a/buglist.cgi +++ b/buglist.cgi @@ -223,12 +223,12 @@ if (defined $cgi->param('regetlastlist')) my $bug_id = $cgi->cookie('BUGLIST'); $bug_id =~ s/:/,/g; # set up the params for this new query - $params = new Bugzilla::CGI({ + $params = { bug_id => $bug_id, bug_id_type => 'anyexact', order => $order, columnlist => scalar($cgi->param('columnlist')), - }); + }; } # Figure out whether or not the user is doing a fulltext search. If not, @@ -421,7 +421,7 @@ if ($cmdtype eq "runnamed") # earlier, for example by setting up a named query search. # This will be modified, so make a copy. -$params ||= new Bugzilla::CGI($cgi); +$params ||= { %{ $cgi->Vars } }; # Generate a reasonable filename for the user agent to suggest to the user # when the user saves the bug list. Uses the name of the remembered query @@ -465,17 +465,16 @@ if ($cmdtype eq "dorem") print $cgi->redirect(-location => $buffer); exit; } - $params = new Bugzilla::CGI($buffer); - $order = $params->param('order') || $order; - + $params = http_decode_query($buffer); + $order = $params->{order} || $order; } elsif ($remaction eq "runseries") { $buffer = LookupSeries(scalar $cgi->param("series_id")); $vars->{searchname} = $cgi->param('namedcmd'); $vars->{searchtype} = "series"; - $params = new Bugzilla::CGI($buffer); - $order = $params->param('order') || $order; + $params = http_decode_query($buffer); + $order = $params->{order} || $order; } elsif ($remaction eq "forget") { @@ -582,9 +581,9 @@ my $columns = Bugzilla::Search::COLUMNS; # Determine the columns that will be displayed in the bug list via the # columnlist CGI parameter, the user's preferences, or the default. my @displaycolumns = (); -if (defined $params->param('columnlist')) +if (defined $params->{columnlist}) { - if ($params->param('columnlist') eq "all") + if ($params->{columnlist} eq 'all') { # If the value of the CGI parameter is "all", display all columns, # but remove the redundant "short_desc" column. @@ -592,7 +591,7 @@ if (defined $params->param('columnlist')) } else { - @displaycolumns = split(/[ ,]+/, $params->param('columnlist')); + @displaycolumns = split(/[ ,]+/, $params->{columnlist}); } } elsif (defined $cgi->cookie('COLUMNLIST')) @@ -633,7 +632,7 @@ $_ = Bugzilla::Search->COLUMN_ALIASES->{$_} || $_ for @displaycolumns; # Some versions of perl will taint 'votes' if this is done as a single # statement, because the votes param is tainted at this point -my $votes = $params->param('votes'); +my $votes = $params->{votes}; $votes ||= ""; if (trim($votes) && !grep($_ eq 'votes', @displaycolumns)) { @@ -838,7 +837,7 @@ my @orderstrings = split(/,\s*/, $order); my $input_bug_status; if ($query_format eq 'specific') { - $input_bug_status = $params->param('bug_status'); + $input_bug_status = $params->{bug_status}; } # Generate the basic SQL query that will be used to generate the bug list. @@ -849,8 +848,7 @@ my $search = new Bugzilla::Search( ); my $query = $search->getSQL(); $vars->{search_description} = $search->search_description_html; -my $H = { %{ $params->Vars } }; -$vars->{list_params} = $H; +$vars->{list_params} = $params; # Generate equality operators for the "Create bug from querystring" link # FIXME: check if there are some differently named fields @@ -1121,14 +1119,16 @@ if ($format->{extension} eq 'ics') } # Restore the bug status used by the specific search. -$params->param('bug_status', $input_bug_status) if $input_bug_status; +$params->{bug_status} = $input_bug_status if $input_bug_status; # The list of query fields in URL query string format, used when creating # URLs to the same query results page with different parameters (such as # a different sort order or when taking some action on the set of query # results). To get this string, we call the Bugzilla::CGI::canoncalise_query # function with a list of elements to be removed from the URL. -$vars->{urlquerypart} = $params->canonicalise_query('order', 'cmdtype', 'query_based_on'); +$vars->{urlquerypart} = { %$params }; +delete $vars->{urlquerypart}->{$_} for ('order', 'cmdtype', 'query_based_on'); +$vars->{urlquerypart} = http_build_query($vars->{urlquerypart}); $vars->{order} = $order; $vars->{order_columns} = [ @orderstrings ]; $vars->{order_dir} = [ map { s/ DESC$// ? 1 : 0 } @{$vars->{order_columns}} ]; @@ -1136,7 +1136,7 @@ $vars->{order_dir} = [ map { s/ DESC$// ? 1 : 0 } @{$vars->{order_columns}} ]; $vars->{caneditbugs} = 1; $vars->{time_info} = $time_info; -$vars->{query_params} = { %{ $params->Vars } }; # now used only in superworktime +$vars->{query_params} = { %$params }; # now used only in superworktime $vars->{query_params}->{chfieldfrom} = $Bugzilla::Search::interval_from; $vars->{query_params}->{chfieldto} = $Bugzilla::Search::interval_to; diff --git a/collectstats.pl b/collectstats.pl index e925f2a7c..63e719375 100755 --- a/collectstats.pl +++ b/collectstats.pl @@ -506,13 +506,13 @@ sub CollectSeriesData { # We set up the user for Search.pm's permission checking - each series # runs with the permissions of its creator. my $user = new Bugzilla::User($serieses->{$series_id}->{'creator'}); - my $cgi = new Bugzilla::CGI($serieses->{$series_id}->{'query'}); + my $query = http_decode_query($serieses->{$series_id}->{'query'}); my $data; # Do not die if Search->new() detects invalid data, such as an obsolete # login name or a renamed product or component, etc. eval { - my $search = new Bugzilla::Search('params' => $cgi, + my $search = new Bugzilla::Search('params' => $query, 'fields' => ["bug_id"], 'user' => $user); my $sql = $search->getSQL(); diff --git a/extensions/custis/lib/Bugzilla/Checker.pm b/extensions/custis/lib/Bugzilla/Checker.pm index f72aa9d15..b1ae61697 100644 --- a/extensions/custis/lib/Bugzilla/Checker.pm +++ b/extensions/custis/lib/Bugzilla/Checker.pm @@ -82,9 +82,8 @@ sub refresh_sql { $query = $self->query; } - my $params = new Bugzilla::CGI($query->url); my $search = new Bugzilla::Search( - params => $params, + params => http_decode_query($query->url), fields => [ 'bug_id' ], user => $query->user, ); diff --git a/extensions/custis/lib/FlushViews.pm b/extensions/custis/lib/FlushViews.pm index 124be6ded..3f407bc64 100644 --- a/extensions/custis/lib/FlushViews.pm +++ b/extensions/custis/lib/FlushViews.pm @@ -4,7 +4,6 @@ package FlushViews; use strict; -use Bugzilla::CGI; use Bugzilla::User; use Bugzilla::Search; @@ -81,11 +80,11 @@ sub refresh_some_views ($q) = $dbh->selectrow_array('SELECT name FROM namedqueries WHERE userid=? AND name LIKE ? LIMIT 1', undef, $userid, $q); $q or next; my $storedquery = Bugzilla::Search::LookupNamedQuery($q, $userid, 0) or next; - my $cgi = new Bugzilla::CGI($storedquery); + $storedquery = http_decode_query($storedquery); # get SQL code my $search = new Bugzilla::Search( - params => $cgi, - fields => [ 'bug_id', grep { $_ ne 'bug_id' } split(/[ ,]+/, $cgi->param('columnlist')||'') ], + params => $storedquery, + fields => [ 'bug_id', grep { $_ ne 'bug_id' } split(/[ ,]+/, $storedquery->{columnlist} || '') ], user => $userobj, ) or next; # Re-create views diff --git a/fill-day-worktime.cgi b/fill-day-worktime.cgi index 87c22ca43..6dd7a6b37 100755 --- a/fill-day-worktime.cgi +++ b/fill-day-worktime.cgi @@ -1,7 +1,7 @@ #!/usr/bin/perl -wT -# -*- Mode: perl; indent-tabs-mode: nil -*- -# ------------------------------------------------------------------------ -# For Bug 12253 +# "Old" version of "Today Worktime" page for mass-filling worktime information (CustIS Bug 12253) +# Author(s): Stas Fomin, Vitaliy Filippov +# License: Dual-license GPL 3.0+ or MPL 1.1+ use strict; use lib qw(. lib); @@ -20,12 +20,12 @@ use BugWorkTime; # extensions/custis/lib/ my $user = Bugzilla->login(LOGIN_REQUIRED); my $userid = $user->id; -my $cgi = Bugzilla->cgi; my $template = Bugzilla->template; my $dbh = Bugzilla->dbh; my $vars = {}; +my $ARGS = { %{ Bugzilla->cgi->Vars } }; -my ($lastdays) = $cgi->param('lastdays') =~ /^(\d+)$/; +my ($lastdays) = $ARGS->{lastdays} =~ /^(\d+)$/; $vars->{lastdays} = $lastdays ||= '1'; sub add_wt @@ -41,24 +41,23 @@ sub add_wt # Read buglist from query params my @idlist; -my $args = { %{ $cgi->Vars } }; -foreach (keys %$args) +foreach (keys %$ARGS) { if (/^wtime_(\d+)/) { my $id = $1; - push @idlist, $id if $args->{$_} || $args->{"comm_$id"} || - $args->{"oldrtime_$id"} ne $args->{"newrtime_$id"}; + push @idlist, $id if $ARGS->{$_} || $ARGS->{"comm_$id"} || + $ARGS->{"oldrtime_$id"} ne $ARGS->{"newrtime_$id"}; } } -my @lines = split("\n", $cgi->param("worktime")); +my @lines = split("\n", $ARGS->{worktime}); if (@idlist || @lines) { my $wtime = { IDS => [] }; foreach my $id (@idlist) { - add_wt($wtime, $id, scalar $cgi->param("wtime_$id"), scalar $cgi->param("comm_$id")); + add_wt($wtime, $id, $ARGS->{"wtime_$id"}, $ARGS->{"comm_$id"}); } foreach my $line (@lines) { @@ -111,7 +110,7 @@ if (@idlist || @lines) Bugzilla->dbh->bz_commit_transaction(); } Checkers::show_checker_errors(); - print $cgi->redirect(-location => "fill-day-worktime.cgi?lastdays=" . $lastdays); + print Bugzilla->cgi->redirect(-location => "fill-day-worktime.cgi?lastdays=" . $lastdays); exit; } @@ -120,9 +119,8 @@ my ($query, $query_id) = Bugzilla::Search::LookupNamedQuery('MyWorktimeBugs', un my $sqlquery = ""; if ($query_id) { - my $queryparams = new Bugzilla::CGI($query); - my $search = new Bugzilla::Search( - params => $queryparams, + my $search = new Bugzilla::Search( + params => http_decode_query($query), fields => [ "bugs.bug_id" ], ); $sqlquery = $search->bugid_query; diff --git a/report.cgi b/report.cgi index 718720f92..e7b79c00e 100755 --- a/report.cgi +++ b/report.cgi @@ -185,10 +185,9 @@ my @axis_fields = @group_by; push @axis_fields, $measures->{$measure} unless $a{$measures->{$measure}}; # Clone the params, so that Bugzilla::Search can modify them -my $params = new Bugzilla::CGI($cgi); my $search = new Bugzilla::Search( 'fields' => \@axis_fields, - 'params' => $params, + 'params' => { %{ $cgi->Vars } }, ); my $query = $search->getSQL(); $query = diff --git a/rss-comments.cgi b/rss-comments.cgi index 007d7f2a7..98e97456e 100755 --- a/rss-comments.cgi +++ b/rss-comments.cgi @@ -1,5 +1,5 @@ #!/usr/bin/perl -wT -# RSS feed bug comments and activity (CustIS Bug 16210) +# RSS feed for bug comments and activity (CustIS Bug 16210) # License: Dual-license GPL 3.0+ or MPL 1.1+ # Author: Vitaliy Filippov @@ -20,42 +20,41 @@ use POSIX; my $user = Bugzilla->login(LOGIN_REQUIRED); my $vars = {}; -my $cgi = Bugzilla->cgi; my $template = Bugzilla->template; my $dbh = Bugzilla->dbh; +my $ARGS = { %{ Bugzilla->cgi->Vars } }; -$vars->{selfurl} = $cgi->canonicalise_query(); -$vars->{buginfo} = $cgi->param('buginfo'); +$vars->{buginfo} = $ARGS->{buginfo}; # See http://lib.custis.ru/ShowTeamWork for &ctype=showteamwork our %FORMATS = map { $_ => 1 } qw(rss showteamwork); -my $who = $cgi->param('who'); +my $who = $ARGS->{who}; my $limit; -my $format = $cgi->param('ctype'); +my $format = $ARGS->{ctype}; trick_taint($format); $FORMATS{$format} or $format = 'rss'; # Determine activity limit (100 by default) -$limit = int($cgi->param('limit')) if $format eq 'showteamwork'; +$limit = int($ARGS->{limit}) if $format eq 'showteamwork'; $limit = 100 if !$limit || $limit < 1; -my $title = $cgi->param('namedcmd'); +my $title = $ARGS->{namedcmd}; if ($title) { my $storedquery = Bugzilla::Search::LookupNamedQuery($title, $user->id); - $cgi = new Bugzilla::CGI($storedquery); + $ARGS = http_decode_query($storedquery); } -$title ||= $cgi->param('query_based_on') || "Bugs"; +$title ||= $ARGS->{query_based_on} || 'Bugs'; -my $queryparams = new Bugzilla::CGI($cgi); -$vars->{urlquerypart} = $queryparams->canonicalise_query('order', 'cmdtype', 'query_based_on'); +delete $ARGS->{$_} for ('order', 'cmdtype', 'query_based_on'); +$vars->{urlquerypart} = http_build_query($ARGS); # Create Bugzilla::Search my $search = new Bugzilla::Search( - params => $queryparams, + params => $ARGS, fields => [ "bug_id" ], ); diff --git a/template/en/default/list/comments.rss.tmpl b/template/en/default/list/comments.rss.tmpl index ae93582ef..eaa7485d2 100644 --- a/template/en/default/list/comments.rss.tmpl +++ b/template/en/default/list/comments.rss.tmpl @@ -6,7 +6,7 @@ [% title FILTER xml %] [% Param('urlbase') %]buglist.cgi?[%- urlquerypart.replace('ctype=rss[&]?','') FILTER xml %] - + [% "$terms.Bugzilla:" FILTER xml %][% title FILTER xml %] en [% builddate %] diff --git a/whine.pl b/whine.pl index 10e9a5e13..ca9636a4f 100755 --- a/whine.pl +++ b/whine.pl @@ -441,14 +441,10 @@ sub run_queries { resolution short_desc ); - # A new Bugzilla::CGI object needs to be created to allow - # Bugzilla::Search to execute a saved query. It's exceedingly weird, - # but that's how it works. - my $searchparams = new Bugzilla::CGI($savedquery); my $search = new Bugzilla::Search( - 'fields' => \@searchfields, - 'params' => $searchparams, - 'user' => $args->{'recipient'}, # the search runs as the recipient + fields => \@searchfields, + params => http_decode_query($savedquery), + user => $args->{recipient}, # the search runs as the recipient ); my $sqlquery = $search->getSQL(); $sth = $dbh->prepare($sqlquery);