diff options
Diffstat (limited to 'Bugzilla.pm')
-rw-r--r-- | Bugzilla.pm | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm index a373aa801..666b1ec15 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -234,6 +234,22 @@ sub cgi { return $class->request_cache->{cgi}; } +sub input_params { + my ($class, $params) = @_; + my $cache = $class->request_cache; + # This is how the WebService and other places set input_params. + if (defined $params) { + $cache->{input_params} = $params; + } + return $cache->{input_params} if defined $cache->{input_params}; + + # Making this scalar makes it a tied hash to the internals of $cgi, + # so if a variable is changed, then it actually changes the $cgi object + # as well. + $cache->{input_params} = $class->cgi->Vars; + return $cache->{input_params}; +} + sub localconfig { my $class = shift; $class->request_cache->{localconfig} ||= read_localconfig(); @@ -647,6 +663,26 @@ The current C<cgi> object. Note that modules should B<not> be using this in general. Not all Bugzilla actions are cgi requests. Its useful as a convenience method for those scripts/templates which are only use via CGI, though. +=item C<input_params> + +When running under the WebService, this is a hashref containing the arguments +passed to the WebService method that was called. When running in a normal +script, this is a hashref containing the contents of the CGI parameters. + +Modifying this hashref will modify the CGI parameters or the WebService +arguments (depending on what C<input_params> currently represents). + +This should be used instead of L</cgi> in situations where your code +could be being called by either a normal CGI script or a WebService method, +such as during a code hook. + +B<Note:> When C<input_params> represents the CGI parameters, any +parameter specified more than once (like C<foo=bar&foo=baz>) will appear +as an arrayref in the hash, but any value specified only once will appear +as a scalar. This means that even if a value I<can> appear multiple times, +if it only I<does> appear once, then it will be a scalar in C<input_params>, +not an arrayref. + =item C<user> C<undef> if there is no currently logged in user or if the login code has not |