Skip to content

Commit

Permalink
Item12952: Finish removing NOT SET handling.
Browse files Browse the repository at this point in the history
Also fix up a couple of checkers that were modifying the configuration:

 - ../ConfigurePlugin/lib/Foswiki/Plugins/ConfigurePlugin.pm

Removed NOT SET processing.  It's no longer used.

 - lib/Foswiki/Configure/Checker.pm

Eliminated guessMajorDir and guessDirectory.  These are not used by
configure. Checkers don't set values

 - lib/Foswiki/Configure/Checkers/BasicSanity.pm
 - lib/Foswiki/Configure/Checkers/DefaultUrlHost.pm
 - lib/Foswiki/Configure/Checkers/SafeEnvPath.pm
 - lib/Foswiki/Configure/Checkers/ScriptUrlPath.pm

Clean up NOT SET processing and guessing of values.

 - lib/Foswiki/Configure/Checkers/DispScriptUrlPath.pm.

Removed.  Once the NOT SET and guess processing was removed there was
nothing left. This variable did not appear to be used.
  • Loading branch information
gac410 committed Sep 29, 2014
1 parent 5a8b8a8 commit 8d503d1
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 161 deletions.
7 changes: 3 additions & 4 deletions ConfigurePlugin/lib/Foswiki/Plugins/ConfigurePlugin.pm
Expand Up @@ -195,7 +195,7 @@ sub _addSpecDefaultsToCfg {
}

# For each key in the spec add the current value from the %cfg
# as current_value. NOT SET values are skipped. If the key is
# as current_value. If the key is
# not set in the %cfg, then set it to the default.
# Note that the %cfg should contain *unexpanded* values.
sub _addCfgValuesToSpec {
Expand All @@ -206,9 +206,8 @@ sub _addCfgValuesToSpec {
}
}
else {
if ( eval("exists(\$cfg->$spec->{keys})")
&& eval("\$cfg->$spec->{keys}") ne "NOT SET" )
{
if ( eval("exists(\$cfg->$spec->{keys})") ) {

# Encode the value as something that can be handled by
# UIs
my $value = eval "\$cfg->$spec->{keys}";
Expand Down
65 changes: 0 additions & 65 deletions core/lib/Foswiki/Configure/Checker.pm
Expand Up @@ -368,71 +368,6 @@ sub warnAboutWindowsBackSlashes {

=begin TML
---++ PROTECTED ObjectMethod guessMajorDir($cfg, $dir, $silent) -> $report
Try and guess the path of one of the major directories, by looking relative
to the absolute pathname of the dir where configure is being run.
=cut

sub guessMajorDir {
my ( $this, $cfg ) = @_;

return $this->guessDirectory( "{$cfg}", undef, @_ );
}

=begin TML
---++ PROTECTED ObjectMethod guessDirectory($keys, $dir, $root, $silent) -> $html
Guesses the location of any directory, not just a major key.
* $keys - the full {key}{spec} to be guessed
* $dir - the default subdirectory name
* $root - {key}{spec} of default parent. undef to use install root.
* $silent - No error if the directory does not exist.
Requires that root directory is valid (or guessed before its subdirectories)
Special case for {ScriptDir}, as that's where the guessing starts for a
brand new install.
=cut

sub guessDirectory {
my ( $this, $keys, $root, $dir, $silent ) = @_;

my $msg = '';
my $val = $this->getCfg($keys);
if ( !$val || $val eq 'NOT SET' || $val eq 'undef' ) {
my $guess;
if ( $keys eq '{ScriptDir}' ) {
require FindBin;
$FindBin::Bin =~ /^(.*)$/;
$guess = $1;
}
else {
my @root =
File::Spec->splitdir( $this->getCfg( $root || '{ScriptDir}' ) );
pop @root unless ($root);
$guess = File::Spec->catfile( @root, $dir );
}
$guess =~ s|\\|/|g;
$this->setItemValue($guess);
$msg = GUESSED_MESSAGE;
$val = $this->getCfg($keys);
}
unless ( $silent || -d $val ) {
my $fwcval = $this->getItemCurrentValue();
$msg .=
$this->ERROR( "Directory '$fwcval'"
. ( $val eq $fwcval ? '' : " ($val)" )
. " does not exist" );
}
return $msg;
}

=begin TML
---++ PROTECTED ObjectMethod showExpandedValue($reporter)
Return the expanded value of a parameter as a note for display.
Expand Down
23 changes: 1 addition & 22 deletions core/lib/Foswiki/Configure/Checkers/BasicSanity.pm
Expand Up @@ -142,25 +142,10 @@ HERE
}
}

# If we got this far without definitions for key variables, then
# we need to default them. otherwise we get peppered with
# 'uninitialised variable' alerts later.
foreach my $var (
qw( DataDir DefaultUrlHost PubUrlPath
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} || '';

if ( $Foswiki::cfg{SafeEnvPath} eq 'NOT SET' ) {
unless ( defined $Foswiki::cfg{SafeEnvPath} ) {

# SMELL: Untaint to get past the first run. It will be
# Overridden to the SafeEnvPath after first save
Expand Down Expand Up @@ -223,12 +208,6 @@ sub _checkCfg {
$mess .= $this->_checkCfg( $entry->[$i], "$keys\[$i]" );
}
}
else {
if ( defined $entry && $entry =~ /NOT SET/ ) {
$mess .=
"<div>\$Foswiki::cfg::$keys has been guessed and may be incorrect</div>";
}
}
return $mess;
}

Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Configure/Checkers/DefaultUrlHost.pm
Expand Up @@ -11,7 +11,7 @@ sub check_current_value {
my ( $this, $reporter ) = @_;

my $d = $this->getCfg();
if ( $d && $d ne 'NOT SET' ) {
if ($d) {
$this->SUPER::check_current_value($reporter);

my $host = $ENV{HTTP_HOST};
Expand Down
45 changes: 0 additions & 45 deletions core/lib/Foswiki/Configure/Checkers/DispScriptUrlPath.pm

This file was deleted.

25 changes: 2 additions & 23 deletions core/lib/Foswiki/Configure/Checkers/ScriptUrlPath.pm
Expand Up @@ -8,37 +8,16 @@ use Foswiki::Configure::Checkers::URLPATH ();
our @ISA = ('Foswiki::Configure::Checkers::URLPATH');

sub check_current_value {
my ($this, $reporter) = @_;
my ( $this, $reporter ) = @_;

# Check Script URL Path against REQUEST_URI
my $value = $this->getCfg();
my $report = '';

# SMELL: using the query, though in this case it looks OK
my $guess = $ENV{REQUEST_URI} || $ENV{SCRIPT_NAME} || '';

if ( !$value || $value eq 'NOT SET' ) {
if ( $guess =~ s{/+configure\b.*$}{} ) {
$reporter->ERROR("No value set; proceeding with a guess '$guess'");
$this->{GuessedValue} = $guess;
$this->SUPER::check_current_value($reporter);
}
else {
$reporter->ERROR(<<"HERE");
This web server does not set REQUEST_URI or SCRIPT_NAME
so this setting cannot be guessed.
HERE
return;
}
$Foswiki::cfg{ScriptUrlPath} = $guess;
$value = $guess;
}

$this->SUPER::check_current_value($reporter);

if ( $value =~ /\/+$/ ) {
$reporter->WARN(
'A trailing / is not recommended');
$reporter->WARN('A trailing / is not recommended');
}
}

Expand Down
1 change: 0 additions & 1 deletion core/lib/Foswiki/Contrib/core/MANIFEST
Expand Up @@ -439,7 +439,6 @@ lib/Foswiki/Configure/Checkers/DATE.pm 0444
lib/Foswiki/Configure/Checkers/DebugFileName.pm 0444
lib/Foswiki/Configure/Checkers/DefaultUrlHost.pm 0444
lib/Foswiki/Configure/Checkers/DisplayTimeValues.pm 0444
lib/Foswiki/Configure/Checkers/DispScriptUrlPath.pm 0444
lib/Foswiki/Configure/Checkers/EMAILADDRESS.pm 0444
lib/Foswiki/Configure/Checkers/Email/EnableSMIME.pm 0444
lib/Foswiki/Configure/Checkers/Email/MailMethod.pm 0444
Expand Down

0 comments on commit 8d503d1

Please sign in to comment.