diff --git a/Bugzilla.pm b/Bugzilla.pm index 2ecba5c17..2995206be 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -303,7 +303,7 @@ sub init_page # Generate and return a message about the downtime, appropriately # for if we're a command-line script or a CGI script. my $extension; - if (i_am_cgi() && (!Bugzilla->cgi->param('ctype') || Bugzilla->cgi->param('ctype') eq 'html')) + if (i_am_cgi() && (!Bugzilla->input_params->{ctype} || Bugzilla->input_params->{ctype} eq 'html')) { $extension = 'html'; } @@ -491,13 +491,13 @@ sub input_params } return $cache->{input_params} if defined $cache->{input_params}; - $cache->{input_params} = {}; my $cgi = $class->cgi; - for ($cgi->param) + my $params = { %{$cgi->{param}} }; + for (keys %$params) { - my @v = $cgi->param($_); - $cache->{input_params}->{$_} = @v <= 1 ? $v[0] : \@v; + ($params->{$_}) = @{$params->{$_}} if @{$params->{$_}} <= 1; } + $cache->{input_params} = $params; return $cache->{input_params}; } @@ -567,7 +567,7 @@ sub login return $class->user if $class->user->id; my $authorizer = new Bugzilla::Auth(); - $type = LOGIN_REQUIRED if $class->cgi->param('GoAheadAndLogIn'); + $type = LOGIN_REQUIRED if Bugzilla->input_params->{GoAheadAndLogIn}; if (!defined $type || $type == LOGIN_NORMAL) { @@ -591,7 +591,7 @@ sub login # 3: There must be a valid value in the 'sudo' cookie # 4: A Bugzilla::User object must exist for the given cookie value # 5: That user must NOT be in the 'bz_sudo_protect' group - my $token = $class->cgi->cookie('sudo'); + my $token = $class->cookies->{sudo}; if (defined $authenticated_user && $token) { my ($user_id, $date, $sudo_target_id) = Bugzilla::Token::GetTokenData($token); @@ -675,6 +675,8 @@ sub logout_request my $class = shift; delete $class->request_cache->{user}; delete $class->request_cache->{sudoer}; + delete $class->cookies->{Bugzilla_login}; + delete $class->cookies->{Bugzilla_logincokie}; # We can't delete from $cgi->cookie, so logincookie data will remain # there. Don't rely on it: use Bugzilla->user->login instead! } @@ -846,7 +848,7 @@ sub switch_to_main_db sub messages { my $class = shift; - my $lc = $class->cgi->cookie('LANG') || 'en'; + my $lc = $class->cookies->{LANG} || 'en'; $lc =~ s/\W+//so; if (!$INC{'Bugzilla::Language::'.$lc}) { diff --git a/Bugzilla/Attachment/PatchReader.pm b/Bugzilla/Attachment/PatchReader.pm index 00e9a287e..c67157db4 100644 --- a/Bugzilla/Attachment/PatchReader.pm +++ b/Bugzilla/Attachment/PatchReader.pm @@ -257,26 +257,25 @@ sub setup_patch_readers { sub setup_template_patch_reader { my ($last_reader, $format, $context, $vars) = @_; - my $cgi = Bugzilla->cgi; my $template = Bugzilla->template; require PatchReader::DiffPrinter::template; # Define the vars for templates. - if (defined $cgi->param('headers')) { - $vars->{'headers'} = $cgi->param('headers'); + if (defined Bugzilla->input_params->{headers}) { + $vars->{'headers'} = Bugzilla->input_params->{headers}; } else { $vars->{'headers'} = 1; } - $vars->{'collapsed'} = $cgi->param('collapsed'); + $vars->{'collapsed'} = Bugzilla->input_params->{collapsed}; $vars->{'context'} = $context; $vars->{'do_context'} = Bugzilla->localconfig->{cvsbin} && Bugzilla->params->{'cvsroot_get'} && !$vars->{'newid'}; # Print everything out. - $cgi->send_header(-type => 'text/html', + Bugzilla->cgi->send_header(-type => 'text/html', -expires => '+3M'); $last_reader->sends_data_to(new PatchReader::DiffPrinter::template($template, diff --git a/Bugzilla/Auth/Login/CGI.pm b/Bugzilla/Auth/Login/CGI.pm index 8941261e0..146dd0b7a 100644 --- a/Bugzilla/Auth/Login/CGI.pm +++ b/Bugzilla/Auth/Login/CGI.pm @@ -55,16 +55,15 @@ sub get_login_info { sub fail_nodata { my ($self) = @_; - my $cgi = Bugzilla->cgi; my $template = Bugzilla->template; if (Bugzilla->usage_mode != USAGE_MODE_BROWSER) { ThrowUserError('login_required'); } - my $format = $cgi->param('format') eq 'simple' ? '-simple' : ''; + my $format = Bugzilla->input_params->{format} eq 'simple' ? '-simple' : ''; $template->process("account/auth/login$format.html.tmpl", - { 'target' => $cgi->url(-relative=>1) }) + { 'target' => Bugzilla->cgi->url(-relative=>1) }) || ThrowTemplateError($template->error()); exit; } diff --git a/Bugzilla/Auth/Login/Cookie.pm b/Bugzilla/Auth/Login/Cookie.pm index 65915f99c..7bd5dd1df 100644 --- a/Bugzilla/Auth/Login/Cookie.pm +++ b/Bugzilla/Auth/Login/Cookie.pm @@ -36,8 +36,8 @@ sub get_login_info { my $dbh = Bugzilla->dbh; my $ip_addr = remote_ip(); - my $login_cookie = $cgi->cookie("Bugzilla_logincookie"); - my $user_id = $cgi->cookie("Bugzilla_login"); + my $login_cookie = Bugzilla->cookies->{Bugzilla_logincookie}; + my $user_id = Bugzilla->cookies->{Bugzilla_login}; # If cookies cannot be found, this could mean that they haven't # been made available yet. In this case, look at Bugzilla_cookie_list. diff --git a/Bugzilla/Auth/Login/FOF_Sudo.pm b/Bugzilla/Auth/Login/FOF_Sudo.pm index fb5b6581e..288b42252 100644 --- a/Bugzilla/Auth/Login/FOF_Sudo.pm +++ b/Bugzilla/Auth/Login/FOF_Sudo.pm @@ -40,7 +40,7 @@ use constant requires_verification => 0; sub get_login_info { my ($self) = @_; - my $cookie = Bugzilla->cgi->cookie('fof_sudo_id'); + my $cookie = Bugzilla->cookies->{fof_sudo_id}; my $server = Bugzilla->params->{fof_sudo_server}; return { failure => AUTH_NODATA } unless $cookie && $server; diff --git a/Bugzilla/Auth/Persist/Cookie.pm b/Bugzilla/Auth/Persist/Cookie.pm index 232212075..65c058626 100644 --- a/Bugzilla/Auth/Persist/Cookie.pm +++ b/Bugzilla/Auth/Persist/Cookie.pm @@ -126,7 +126,7 @@ sub logout { $login_cookie = $cookie->value; } else { - $login_cookie = $cgi->cookie("Bugzilla_logincookie"); + $login_cookie = Bugzilla->cookies->{Bugzilla_logincookie}; } trick_taint($login_cookie); diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 8af452d1b..09f632f0f 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -942,9 +942,9 @@ sub check_dependent_fields my $verify_bug_groups = undef; if ($self->id && $self->{_old_self}->product_id != $self->product_id) { - # FIXME Do not call CGI from Bugzilla::Bug! - if (!Bugzilla->cgi->param('verify_bug_groups') && - Bugzilla->cgi->param('id')) + # FIXME Do not use input_params from Bugzilla::Bug + if (!Bugzilla->input_params->{verify_bug_groups} && + Bugzilla->input_params->{id}) { # Display group verification message only for single bug changes # Get the ID of groups which are no longer valid in the new product. @@ -1487,8 +1487,8 @@ sub save_added_comments delete $self->{comments} if @{$self->{added_comments} || []}; foreach my $comment (@{$self->{added_comments} || []}) { - # FIXME Don't talk to CGI from here - if (Bugzilla->cgi->param('commentsilent')) + # FIXME Do not use input_params from Bugzilla::Bug + if (Bugzilla->input_params->{commentsilent}) { # Log silent comments SilentLog($self->id, $comment->{thetext}); @@ -1963,10 +1963,9 @@ sub _set_dup_id # not adding the user, as the safest option. elsif (Bugzilla->usage_mode == USAGE_MODE_BROWSER) { - # FIXME Don't talk to CGI from Bugzilla::Bug + # FIXME Do not use input_params from Bugzilla::Bug # If we've already confirmed whether the user should be added... - my $cgi = Bugzilla->cgi; - my $add_confirmed = $cgi->param('confirm_add_duplicate'); + my $add_confirmed = Bugzilla->input_params->{confirm_add_duplicate}; if (defined $add_confirmed) { $add_dup_cc = $add_confirmed; @@ -1985,7 +1984,6 @@ sub _set_dup_id $vars->{cclist_accessible} = $dupe_of_bug->cclist_accessible; $vars->{original_bug_id} = $dupe_of; $vars->{duplicate_bug_id} = $self->id; - $cgi->send_header(); $template->process("bug/process/confirm-duplicate.html.tmpl", $vars) || ThrowTemplateError($template->error); exit; diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index 6fa465d30..ed3f76f2a 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -94,8 +94,8 @@ sub send_results elsif ($vars->{message} eq 'bugmail') { $vars->{sent_bugmail} = Send($vars->{bug_id}, $vars->{mailrecipients}, $vars->{commentsilent}); - # FIXME Don't take commentsilent from cgi here - $vars->{commentsilent} = Bugzilla->cgi->param('commentsilent') ? 1 : 0; + # FIXME Do not use input_params from Bugzilla::BugMail + $vars->{commentsilent} = Bugzilla->input_params->{commentsilent} ? 1 : 0; } return $vars; } diff --git a/Bugzilla/CheckerUtils.pm b/Bugzilla/CheckerUtils.pm index 8cd05fb9f..0426f5062 100644 --- a/Bugzilla/CheckerUtils.pm +++ b/Bugzilla/CheckerUtils.pm @@ -95,7 +95,7 @@ sub alert push(@warn, $_); } } - my $force = 1 && Bugzilla->cgi->param('force_checkers'); + my $force = 1 && Bugzilla->input_params->{force_checkers}; if (!@fatal && (!@warn || $force)) { # Either there are no errors or there are only non-fatal ones and the used clicked "DO WHAT I SAY" diff --git a/Bugzilla/Flag.pm b/Bugzilla/Flag.pm index 177a7a863..96abc0e30 100644 --- a/Bugzilla/Flag.pm +++ b/Bugzilla/Flag.pm @@ -1109,7 +1109,7 @@ sub notify } # FIXME move "silent" indication out of cgi.commentsilent - if (Bugzilla->cgi->param('commentsilent') && + if (Bugzilla->input_params->{commentsilent} && Bugzilla->user->settings->{silent_affects_flags}->{value} eq 'do_not_send') { # Your changes are marked as Silent. No mail is sent. diff --git a/Bugzilla/Install/Util.pm b/Bugzilla/Install/Util.pm index 3f23897de..37d89bfcb 100644 --- a/Bugzilla/Install/Util.pm +++ b/Bugzilla/Install/Util.pm @@ -175,7 +175,7 @@ sub include_languages { # Bugzilla:Util::i_am_cgi. if (exists $ENV{'SERVER_SOFTWARE'}) { my $cgi = Bugzilla->cgi; - if (defined (my $lang = $cgi->cookie('LANG'))) { + if (defined (my $lang = Bugzilla->cookies->{LANG})) { unshift @wanted, $lang; } } diff --git a/Bugzilla/Mailer.pm b/Bugzilla/Mailer.pm index 49e4e0145..d52cf9214 100644 --- a/Bugzilla/Mailer.pm +++ b/Bugzilla/Mailer.pm @@ -55,7 +55,7 @@ use Email::Sender::Simple; sub MessageToMTA { my ($msg, $send_now) = (@_); my $method = Bugzilla->params->{'mail_delivery_method'}; - $method = 'Test' if Bugzilla->cgi->param('MailDeliveryTest'); + $method = 'Test' if Bugzilla->input_params->{MailDeliveryTest}; return if $method eq 'None'; if (Bugzilla->params->{'use_mailer_queue'} and !$send_now) { diff --git a/Bugzilla/Product.pm b/Bugzilla/Product.pm index 0a4bf42ab..f64b02438 100644 --- a/Bugzilla/Product.pm +++ b/Bugzilla/Product.pm @@ -1118,7 +1118,7 @@ sub choose_product ThrowUserError('no_products') unless @$products; return $products->[0] if @$products == 1; - my $qp = { %$query_params }; + my $qp = { %{ $query_params || Bugzilla->input_params } }; delete $qp->{classification}; $qp = http_build_query($qp); $qp .= '&' if length $qp; diff --git a/Bugzilla/Search/Quicksearch.pm b/Bugzilla/Search/Quicksearch.pm index 798ad17e6..2b6517fd7 100644 --- a/Bugzilla/Search/Quicksearch.pm +++ b/Bugzilla/Search/Quicksearch.pm @@ -221,7 +221,7 @@ sub quicksearch delete $ARGS->{$_} for ('quicksearch', 'load', 'run'); my $order; - if ($order = Bugzilla->cgi->cookie('LASTORDER')) + if ($order = Bugzilla->cookies->{LASTORDER}) { $order =~ s/relevance(\s*(a|de)sc)?,|,relevance(\s*(a|de)sc)?//iso; $order = "relevance DESC,$order"; diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 02244ad6e..0a2ebe0b3 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -1047,15 +1047,6 @@ sub create { # FIXME find a better place for this function 'use_keywords' => sub { return Bugzilla::Keyword->any_exist; }, - 'last_bug_list' => sub { - my @bug_list; - my $cgi = Bugzilla->cgi; - if ($cgi->cookie("BUGLIST")) { - @bug_list = split(/:/, $cgi->cookie("BUGLIST")); - } - return \@bug_list; - }, - 'feature_enabled' => sub { return Bugzilla->feature(@_); }, 'install_string' => \&Bugzilla::Install::Util::install_string, @@ -1221,9 +1212,7 @@ Bugzilla::Template - Wrapper around the Template Toolkit C