Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item13010: don't die when there's no LocalSite.cfg
also, make sure some ENV is not undefined:

- REQUEST_URI
- PATH_INFO
- SCRIPT_NAME
  • Loading branch information
MichaelDaum committed Dec 19, 2014
1 parent 9594a73 commit 1e64875
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/Foswiki/Engine/FastCGI.pm
Expand Up @@ -68,6 +68,11 @@ sub run {
&FCGI::FAIL_ACCEPT_ON_INTR );
my $manager;

# make sure some ENV vars are set
$ENV{"REQUEST_URI"} = '' unless defined $ENV{REQUEST_URI};
$ENV{"PATH_INFO"} = '' unless defined $ENV{PATH_INFO};
$ENV{"SCRIPT_NAME"} = 'foswiki.fcgi' unless defined $ENV{SCRIPT_NAME};

if ($listen) {
$args->{manager} ||= 'Foswiki::Engine::FastCGI::ProcManager';
$args->{nproc} ||= 1;
Expand Down Expand Up @@ -112,10 +117,8 @@ sub run {
}

my $localSiteCfg = $INC{'LocalSite.cfg'};
die "LocalSite.cfg is not loaded - Check permissions or run configure\n"
unless defined $localSiteCfg;

my $lastMTime = ( stat $localSiteCfg )[9];
my $lastMTime = 0;
$lastMTime = ( stat $localSiteCfg )[9] if defined $localSiteCfg;

while ( $r->Accept() >= 0 ) {
$manager && $manager->pm_pre_dispatch();
Expand All @@ -127,7 +130,9 @@ sub run {
$this->finalize( $res, $req );
}

my $mtime = ( stat $localSiteCfg )[9];
my $mtime = 0;
$mtime = ( stat $localSiteCfg )[9] if defined $localSiteCfg;

if ( $mtime > $lastMTime || $hupRecieved ) {
$r->LastCall();
if ($manager) {
Expand All @@ -140,7 +145,7 @@ sub run {
$manager && $manager->pm_post_dispatch();
}
reExec() if $hupRecieved;
closeSocket($sock);
closeSocket();
}

sub preparePath {
Expand Down

0 comments on commit 1e64875

Please sign in to comment.