Skip to content

Commit

Permalink
Item13220: Handle bootstrap better in CLI env.
Browse files Browse the repository at this point in the history
Avoid "Undefined" errors if cgi scripts are run in a CLI
environment before a config has been created.
  • Loading branch information
gac410 committed Feb 4, 2015
1 parent 268674d commit 8e534c4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions core/lib/Foswiki/Configure/Load.pm
Expand Up @@ -392,7 +392,7 @@ sub bootstrapConfig {
$bin = $ENV{FOSWIKI_SCRIPTS};
}
else {
eval( 'require FindBin' );
eval('require FindBin');
die "Could not load FindBin to support configuration recovery: $@"
if $@;
FindBin::again(); # in case we are under mod_perl or similar
Expand Down Expand Up @@ -607,13 +607,21 @@ Called by bootstrapConfig. This handles the web environment specific settings o
sub bootstrapWebSettings {
my $script = shift;

# Cannot bootstrap the web side from CLI environments
return if ( $Foswiki::cfg{Engine} eq 'Foswiki::Engine::CLI' );

print STDERR "AUTOCONFIG: Bootstrap Phase 2: "
. Data::Dumper::Dumper( \%ENV )
if (TRAUTO);

# Cannot bootstrap the web side from CLI environments
if ( $Foswiki::cfg{Engine} eq 'Foswiki::Engine::CLI' ) {
$Foswiki::cfg{DefaultUrlHost} = 'http://localhost';
$Foswiki::cfg{ScriptUrlPath} = '/bin';
$Foswiki::cfg{PubUrlPath} = '/pub';
print STDERR
"AUTOCONFIG: Bootstrap Phase 2 bypassed! n/a in the CLI Environment\n"
if (TRAUTO);
return 'Phase 2 boostrap bypassed - n/a in CLI environment\n';
}

my $protocol = $ENV{HTTPS} ? 'https' : 'http';

# Figure out the DefaultUrlHost
Expand Down

0 comments on commit 8e534c4

Please sign in to comment.