Skip to content

Commit

Permalink
Item11690: Revert fixes from Release 1.1
Browse files Browse the repository at this point in the history
After these changes, it is no longer possible to cancel a save.  The
Cancel leaves the user on a blank screen.

We also don't have any unit tests for redirect, so with this issue, it's
probably best to defer the changes for Foswiki 1.2.

git-svn-id: http://svn.foswiki.org/branches/Release01x01@14497 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Mar 29, 2012
1 parent e8d8ab8 commit a775d0a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
14 changes: 5 additions & 9 deletions core/lib/Foswiki.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1109,17 +1109,16 @@ sub splitAnchorFromUrl {

=begin TML
---++ ObjectMethod redirect( $url, $passthrough, $status )
---++ ObjectMethod redirect( $url, $passthrough )
* $url - url or topic to redirect to
* $passthrough - (optional) parameter to pass through current query
parameters (see below)
* $status - HTTP status code (30x) to redirect with. Defaults to 302.
Redirects the request to =$url=, *unless*
1 It is overridden by a plugin declaring a =redirectCgiQueryHandler=
(a dangerous, deprecated handler!)
1 =$session->{request}= is =undef=
1 =$session->{request}= is =undef= or
Thus a redirect is only generated when in a CGI context.
Normally this method will ignore parameters to the current query. Sometimes,
Expand All @@ -1139,7 +1138,7 @@ server.
=cut

sub redirect {
my ( $this, $url, $passthru, $status ) = @_;
my ( $this, $url, $passthru ) = @_;
ASSERT( defined $url ) if DEBUG;

return unless $this->{request};
Expand Down Expand Up @@ -1209,11 +1208,8 @@ sub redirect {
# Foswiki::Response::redirect doesn't automatically pass on the cookies
# for us, so we have to do it explicitly; otherwise the session cookie
# won't get passed on.
$this->{response}->redirect(
-url => $url,
-cookies => $this->{response}->cookies(),
-status => $status,
);
$this->{response}
->redirect( -url => $url, -cookies => $this->{response}->cookies() );
}

=begin TML
Expand Down
11 changes: 4 additions & 7 deletions core/lib/Foswiki/Func.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2640,17 +2640,16 @@ sub writeHeader {

=begin TML
---+++ redirectCgiQuery( $query, $url, $passthru, $status )
---+++ redirectCgiQuery( $query, $url, $passthru )
Redirect to URL
* =$query= - CGI query object. Ignored, only there for compatibility. The session CGI query object is used instead.
* =$url= - URL to redirect to
* =$passthru= - enable passthrough.
* =$status= - HTTP status code (30x) to redirect with. Optional, defaults to 302. *Since* 2012-03-28
Return: none
Issue a =Location= HTTP header that will cause a redirect to a new URL.
Print output to STDOUT that will cause a 302 redirect to a new URL.
Nothing more should be printed to STDOUT after this method has been called.
The =$passthru= parameter allows you to pass the parameters that were passed
Expand All @@ -2676,11 +2675,9 @@ Foswiki installation.
=cut

sub redirectCgiQuery {
my ( $query, $url, $passthru, $status ) = @_;
my ( $query, $url, $passthru ) = @_;
ASSERT($Foswiki::Plugins::SESSION) if DEBUG;
writeWarning("redirectCgiQuery: not a valid redirect status: $status")
if $status && $status !~ /^\s*3\d\d.*/;
return $Foswiki::Plugins::SESSION->redirect( $url, $passthru, $status );
return $Foswiki::Plugins::SESSION->redirect( $url, $passthru );
}

=begin TML
Expand Down
5 changes: 3 additions & 2 deletions core/lib/Foswiki/Request.pm
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ sub header {
---++ ObjectMethod save( $fh )
Saves object state to filehandle. Object may be loaded later
Saves object state to filehandle. Object may be loaded latter
passing $fh to new constructor or by calling load().
=cut
Expand All @@ -579,9 +579,10 @@ sub save {
my ( $this, $fh ) = @_;
local ( $\, $, ) = ( '', '' );
foreach my $name ( $this->param ) {
my $key = Foswiki::urlEncode($name);
foreach my $value ( $this->param($name) ) {
$value = '' unless defined $value;
print $fh Foswiki::urlEncode($name), '=',
print $fh Foswiki::urlEncode($key), '=',
Foswiki::urlEncode($value), "\n";
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Request/Cache.pm
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ sub load {
my $here = tell $F;
while ( my $l = <$F> ) {
last if $l =~ /^=/;
print STDERR "CACHE $uid< " . Foswiki::urlDecode($l);
print STDERR "CACHE $uid< $l";
}
seek( $F, $here, 0 );
}
Expand Down

0 comments on commit a775d0a

Please sign in to comment.