Skip to content

Commit

Permalink
Item13897: Bug fixes.
Browse files Browse the repository at this point in the history
My local setup displays bootstrap configuration page.
  • Loading branch information
vrurg committed Mar 3, 2016
1 parent 2b3bf65 commit 73cc52f
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 143 deletions.
2 changes: 1 addition & 1 deletion core/lib/Foswiki/AccessControlException.pm
Expand Up @@ -24,7 +24,7 @@ If your code needs to abort processing and inform the user (or the higher level
that some operation was denied, throw an =AccessControlException=.
<verbatim>
use Error qw(:try);
use Try::Tiny;
use Foswiki::AccessControlException;
...
unless (
Expand Down
83 changes: 42 additions & 41 deletions core/lib/Foswiki/Engine/CGI.pm
Expand Up @@ -82,58 +82,59 @@ has cgi => (
clearer => 1,
isa => Foswiki::Object::isaCLASS( 'cgi', 'CGI' ),
);
has uploads => ( is => 'rw', lazy => 1, clearer => 1, default => sub { {} }, );

sub run {
my $this = shift;
my $req = $this->prepare;
my $requestor = $req->http('x-requested-with') || '';
unless (
$Foswiki::cfg{isVALID}
|| $Foswiki::cfg{isBOOTSTRAPPING}
|| $requestor eq 'XMLHttpRequest'

# Configure uses FoswikiReflectionRequest to query values
# before LSC is ready
|| $requestor eq 'FoswikiReflectionRequest'
)
{
print STDOUT "Content-type: text/html\n\n";
print STDOUT '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
. "\n "
. '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
print STDOUT
my $this = shift;
try {
my $req = $this->prepare;
my $requestor = $req->http('x-requested-with') || '';
unless (
$Foswiki::cfg{isVALID}
|| $Foswiki::cfg{isBOOTSTRAPPING}
|| $requestor eq 'XMLHttpRequest'

# Configure uses FoswikiReflectionRequest to query values
# before LSC is ready
|| $requestor eq 'FoswikiReflectionRequest'
)
{
print STDOUT "Content-type: text/html\n\n";
print STDOUT
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
. "\n "
. '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
print STDOUT
"<html><head></head><body><h1>Foswiki Configuration Error</h1><br>Please run <code>configure</code> to create a valid configuration<br />\n";
print STDOUT
print STDOUT
"If you've already done this, then your <code>lib/LocalSite.cfg</code> is most likely damaged\n</body></html>";
exit 1;
}
if ( UNIVERSAL::isa( $req, 'Foswiki::Request' ) ) {
try {
exit 1;
}
if ( UNIVERSAL::isa( $req, 'Foswiki::Request' ) ) {
my $res = Foswiki::UI::handleRequest($req);
$this->finalize( $res, $req );
}
catch {
}
catch {
# Whatever error we get here – we generate valid HTTP response. At least we try...
# This is the last frontier of error handling.
# SMELL XXX Test code.

# SMELL This block is to be reconsidered.
if ( !ref($_) ) {
say STDERR "CGI::catch simple text: $_";
CGI::Carp::confess($_);
}
elsif ( $_->isa('Error') || $_->isa('Error::Simple') ) {
say STDERR "CGI::catch Error derivative: $_->{-text}";
CGI::Carp::confess( $_->{-text} );
}
else {
say STDERR "CGI::catch Foswiki::Exception derivative: ",
$_->text;
CGI::Carp::confess( $_->text );
}

};
}
# SMELL This block is to be reconsidered.
if ( !ref($_) ) {
say STDERR "CGI::catch simple text: $_";
CGI::Carp::confess($_);
}
elsif ( $_->isa('Error') || $_->isa('Error::Simple') ) {
say STDERR "CGI::catch Error derivative: $_->{-text}";
CGI::Carp::confess( $_->{-text} );
}
else {
say STDERR "CGI::catch Foswiki::Exception derivative: ", $_->text;
CGI::Carp::confess( $_->text );
}

};
}

sub prepareConnection {
Expand Down
9 changes: 6 additions & 3 deletions core/lib/Foswiki/Engine/CLI.pm
Expand Up @@ -23,7 +23,10 @@ use Moo;
use namespace::clean;
extends qw(Foswiki::Engine);

has path_info => ( is => 'rw', );
has path_info => ( is => 'rw', predicate => 1, );
has user => ( is => 'rw', );
has plist => ( is => 'rw', lazy => 1, clearer => 1, default => sub { [] }, );
has params => ( is => 'rw', lazy => 1, clearer => 1, default => sub { {} }, );

BEGIN {
if ( $Foswiki::cfg{UseLocale} ) {
Expand Down Expand Up @@ -115,13 +118,13 @@ sub prepareUploads {

#SMELL: CLI and CGI appear to support multiple uploads
# but Foswiki::UI::Upload only processes a single upload.
foreach my $fname ( @{ $req->param->{filepath} } ) {
foreach my $fname ( @{ $req->_param->{filepath} } ) {
$uploads{$fname} = Foswiki::Request::Upload->new(
headers => {},
tmpname => $fname
);
}
$this->clear_uploads;
$req->clear_uploads;
$req->uploads( \%uploads );
}

Expand Down
23 changes: 15 additions & 8 deletions core/lib/Foswiki/Engine/Legacy.pm
Expand Up @@ -29,13 +29,15 @@ our @ISA;
my ( $request, $response );

BEGIN {
use Moo;
if ( $ENV{GATEWAY_INTERFACE} ) {
require Foswiki::Engine::CGI;
@ISA = qw(Foswiki::Engine::CGI);

#require Foswiki::Engine::CGI;
extends qw(Foswiki::Engine::CGI);
}
else {
require Foswiki::Engine::CLI;
@ISA = qw(Foswiki::Engine::CLI);
#require Foswiki::Engine::CLI;
extends qw(Foswiki::Engine::CLI);
}
no warnings 'redefine';
require Foswiki::Request;
Expand All @@ -61,13 +63,18 @@ BEGIN {
require Foswiki::EngineException;
}

sub new {
sub BUILD {
my $this = shift;
$this = $this->SUPER::new(@_);
$this->prepare();
return $this;
$this->prepare;
}

#sub new {
# my $this = shift;
# $this = $this->SUPER::new(@_);
# $this->prepare();
# return $this;
#}

END {
$Foswiki::engine->finalize( $response, $request )
if ref($response) && $response->isa('Foswiki::Response');
Expand Down
18 changes: 9 additions & 9 deletions core/lib/Foswiki/Func.pm
Expand Up @@ -1446,7 +1446,7 @@ in =ThatWeb.ThisTopic=, then a call to =checkAccessPermission('SPIN', 'IncyWincy
*Example code:*
<verbatim>
use Error qw(:try);
use Try::Tiny;
use Foswiki::AccessControlException;
...
unless (
Expand Down Expand Up @@ -1790,7 +1790,7 @@ read to be successful. Access control violations are flagged by a
Foswiki::AccessControlException. Permissions are checked for the current user.
<verbatim>
use Error qw(:try);
use Try::Tiny;
use Foswiki::AccessControlException ();
my( $meta, $text ) = Foswiki::Func::readTopic( $web, $topic );
Expand Down Expand Up @@ -1865,7 +1865,7 @@ sub readAttachment {
the web preferences topic in the new web.
<verbatim>
use Error qw( :try );
use Try::Tiny;
use Foswiki::AccessControlException ();
try {
Expand Down Expand Up @@ -1935,7 +1935,7 @@ sub createWeb {
Move (rename) a web.
<verbatim>
use Error qw( :try );
use Try::Tiny;
use Foswiki::AccessControlException ();
try {
Expand Down Expand Up @@ -2074,7 +2074,7 @@ sub setTopicEditLock {
| =ignorepermissions= | don't check acls |
For example,
<verbatim>
use Error qw( :try );
use Try::Tiny;
use Foswiki::AccessControlException ();
my( $meta, $text );
Expand Down Expand Up @@ -2154,7 +2154,7 @@ The destination topic must not already exist.
Rename a topic to the $Foswiki::cfg{TrashWebName} to delete it.
<verbatim>
use Error qw( :try );
use Try::Tiny;
try {
moveTopic( "Work", "TokyoOffice", "Trash", "ClosedOffice" );
Expand Down Expand Up @@ -2293,7 +2293,7 @@ The destination topic must already exist, but the destination attachment must
Rename an attachment to $Foswiki::cfg{TrashWebName}.TrashAttament to delete it.
<verbatim>
use Error qw( :try );
use Try::Tiny;
try {
# move attachment between topics
Expand Down Expand Up @@ -2384,7 +2384,7 @@ The destination topic must already exist, but the destination attachment must
*not* exist.
<verbatim>
use Error qw( :try );
use Try::Tiny;
try {
# copy attachment between topics
Expand Down Expand Up @@ -3494,7 +3494,7 @@ Return: =$url= URL, e.g. ="http://example.com:80/cgi-bin/oop
*Deprecated* 28 Nov 2008, the recommended approach is to throw an oops exception.
<verbatim>
use Error qw( :try );
use Try::Tiny;
Foswiki::OopsException->throw(
'toestuckerror',
Expand Down
3 changes: 2 additions & 1 deletion core/lib/Foswiki/Request.pm
Expand Up @@ -78,9 +78,10 @@ has uploads => (
is => 'rw',
lazy => 1,
default => sub { {} },
clearer => 1,
isa => Foswiki::Object::isaHASH( 'uploads', noUndef => 1 ),
);
has param_list => ( is => 'rw', lazy => 1, default => sub { [] }, );
has param_list => ( is => 'rw', lazy => 1, default => sub { return []; }, );
has method => ( is => 'rw', );
has remote_user => ( is => 'rw', );
has server_port => ( is => 'rw', );
Expand Down

0 comments on commit 73cc52f

Please sign in to comment.