Skip to content

Commit

Permalink
Item12952: more improved handling of bootstrap
Browse files Browse the repository at this point in the history
 - Added code to bootstrap ScriptSuffix and corrected a couple of other
   errors.

For now I've un-commented {ScriptUrlPaths}{view}   configure is not
saving that field when set during the bootstrap.  Could not figure out
why.
  • Loading branch information
gac410 committed Sep 2, 2014
1 parent cc42a89 commit aa4df4c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
11 changes: 10 additions & 1 deletion core/lib/Foswiki.pm
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,19 @@ BEGIN {
if ( $ENV{SCRIPT_NAME} ) {
print STDERR "AUTOCONFIG: Found SCRIPT $ENV{SCRIPT_NAME} \n"
if (TRAUTO);

$Foswiki::cfg{ScriptSuffix} =
( $ENV{SCRIPT_NAME} =~ /(\.[^.]*)$/ ) ? $1 : '';
print STDERR
"AUTOCONFIG: Found SCRIPT SUFFIX $Foswiki::cfg{ScriptSuffix} \n"
if ( TRAUTO && $Foswiki::cfg{ScriptSuffix} );

if ( $ENV{SCRIPT_NAME} =~ m{^(.*?)/$script(\b|$)} ) {

# Conventional URLs with path and script
$Foswiki::cfg{ScriptUrlPath} = $1;
$Foswiki::cfg{ScriptUrlPaths}{view} =
$1 . '/view' . $Foswiki::cfg{ScriptSuffix};

# This might not work, depending on the websrver config,
# but it's the best we can do
Expand All @@ -424,7 +433,7 @@ BEGIN {
"AUTOCONFIG: Found path, but no script. short URLs \n"
if (TRAUTO);
$Foswiki::cfg{ScriptUrlPath} = $ENV{SCRIPT_NAME} . '/bin';
$Foswiki::cfg{'ScriptUrlPaths'}{'view'} = '';
$Foswiki::cfg{ScriptUrlPaths}{view} = $ENV{SCRIPT_NAME};
$Foswiki::cfg{PubUrlPath} = $ENV{SCRIPT_NAME} . '/pub';
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki.spec
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ $Foswiki::cfg{PathCheckLimit} = 7000;
# **STRING 10**
# Suffix of Foswiki CGI scripts (e.g. .cgi or .pl). You may need to set this
# if your webserver requires an extension.
$Foswiki::cfg{ScriptSuffix} = '';
#$Foswiki::cfg{ScriptSuffix} = '';

# **URLPATH CHECK='expand nullok notrail' FEEDBACK="label='Verify';wizard='ScriptHash';method='verify';auth=1" UNDEFINEDOK MANDATORY**
#! n.b. options should match Pluggables/SCRIPTHASH.pm for dynamic path items
Expand Down
7 changes: 5 additions & 2 deletions core/lib/Foswiki/Configure/Checkers/BasicSanity.pm
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ HERE
else {

# Doesn't exist (yet)
my $errs = Foswiki::Configure::FileUtil::checkCanCreateFile( $this->{LocalSiteDotCfg} );
my $errs = Foswiki::Configure::FileUtil::checkCanCreateFile(
$this->{LocalSiteDotCfg} );

if ($errs) {
$this->{errorcount}++;
Expand All @@ -146,13 +147,15 @@ HERE
# 'uninitialised variable' alerts later.
foreach my $var (
qw( DataDir DefaultUrlHost PubUrlPath
PubDir TemplateDir ScriptUrlPath LocalesDir SafeEnvPath )
PubDir TemplateDir ScriptUrlPath ScriptSuffix LocalesDir SafeEnvPath )
)
{

# NOT SET tells the checker to try and guess the value later on
$Foswiki::cfg{$var} = 'NOT SET' unless defined $Foswiki::cfg{$var};
}
$Foswiki::cfg{ScriptUrlPaths}{view} = 'NOT SET'
unless defined $Foswiki::cfg{ScriptUrlPaths}{view};

# Make %ENV safer for CGI - Assign a safe default for SafeEnvPath
$Foswiki::cfg{DETECTED}{originalPath} = $ENV{PATH} || '';
Expand Down
8 changes: 7 additions & 1 deletion core/lib/Foswiki/Configure/Load.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ our $TRUE = 1;
our $FALSE = 0;

our @NOT_SET = qw( DataDir DefaultUrlHost PubUrlPath ToolsDir WorkingDir
PubDir TemplateDir ScriptDir ScriptUrlPath LocalesDir );
PubDir TemplateDir ScriptDir ScriptUrlPath ScriptSuffix LocalesDir );

# {ScriptUrlPaths}{view} is also processed as NOT_SET

# Configuration items that have been deprecated and must be mapped to
# new configuration items. The value is mapped unchanged.
Expand Down Expand Up @@ -159,6 +161,10 @@ GOLLYGOSH
$validLSC = 0;
}
}
unless ( defined $Foswiki::cfg{ScriptUrlPaths}{view} ) {
$Foswiki::cfg{ScriptUrlPaths}{view} = 'NOT SET';
$validLSC = 0;
}

# Patch deprecated config settings
if ( exists $Foswiki::cfg{StoreImpl} ) {
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Configure/Pluggables/SCRIPTHASH.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ sub construct {
my $default;

if ( $Foswiki::cfg{ScriptSuffix} ) {
next unless $filename =~ /^(.*)\.$Foswiki::cfg{ScriptSuffix}$/;
next unless $filename =~ /^(.*)$Foswiki::cfg{ScriptSuffix}$/;
$script = $1;
$default =
"\$Foswiki::cfg{ScriptUrlPath}/$1\$Foswiki::cfg{ScriptSuffix}";
Expand Down

0 comments on commit aa4df4c

Please sign in to comment.