Skip to content

Commit

Permalink
Item1333: add Foswiki::Func::getRequestObject and deprecate getCgiQuery
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@3197 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
CrawfordCurrie authored and CrawfordCurrie committed Mar 19, 2009
1 parent 2b4717d commit 7965f76
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion UnitTestContrib/test/unit/FuncTests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ sub test_setPreferences {
Foswiki::Func::setPreferencesValue( "PSIBG", "KJHD" );
$this->assert_str_equals( "KJHD",
Foswiki::Func::getPreferencesValue("PSIBG") );
my $q = Foswiki::Func::getCgiQuery();
my $q = Foswiki::Func::getRequestObject();

####
Foswiki::Func::saveTopicText( $this->{test_web},
Expand Down
24 changes: 19 additions & 5 deletions core/lib/Foswiki/Func.pm
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,17 @@ sub getExternalResource {

=begin TML
---+++ getCgiQuery( ) -> $query
---+++ getRequestObject( ) -> $query
Get CGI query object. Important: Plugins cannot assume that scripts run under CGI, Plugins must always test if the CGI query object is set
Get the request object. This is a subclass of Foswiki::Request. The request
object can be used to get the parameters passed to the request, either
via CGI or on the command ine (depending on how the script was called).
Return: =$query= CGI query object; or 0 if script is called as a shell script
*Since:* 31 Mar 2009
=cut

sub getCgiQuery {
sub getRequestObject {
ASSERT($Foswiki::Plugins::SESSION) if DEBUG;
return $Foswiki::Plugins::SESSION->{request};
}
Expand Down Expand Up @@ -1623,6 +1625,8 @@ sub readTopicText {
---+++ getAttachmentList( $web, $topic ) -> @list
Get a list of the attachments on the given topic.
*Since:* 31 Mar 2009
=cut

sub getAttachmentList {
Expand Down Expand Up @@ -1921,7 +1925,7 @@ when the old parameters are restored. if you want to change any parameter
values, you will need to do that in the current CGI query before redirecting
e.g.
<verbatim>
my $query = Foswiki::Func::getCgiQuery();
my $query = Foswiki::Func::getRequestObject();
$query->param(-name => 'text', -value => 'Different text');
Foswiki::Func::redirectCgiQuery(
undef, Foswiki::Func::getScriptUrl($web, $topic, 'edit'), 1);
Expand Down Expand Up @@ -2929,6 +2933,16 @@ sub getDataDir {

sub getPubDir { return $Foswiki::cfg{PubDir}; }

=begin TML
---+++ getCgiQuery( ) -> $query
*Deprecated* 31 Mar 2009 - use getRequestObject instead.
=cut

sub getCgiQuery { return getRequestObject(); }

# Removed; it was never used
sub checkDependencies {
die
Expand Down

0 comments on commit 7965f76

Please sign in to comment.