Skip to content

Commit

Permalink
Item9403: Pass back sanity errors to Configure UI
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@8344 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Jul 29, 2010
1 parent 8ca8349 commit 08d252e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 12 additions & 5 deletions core/bin/configure
Expand Up @@ -278,6 +278,7 @@ our $query = new CGI;
my $TRUE = 1;
my $FALSE = 0;
our $badLSC;
our $insane;
our $time = time();

my $url = $query->url();
Expand Down Expand Up @@ -445,12 +446,14 @@ sub _dispatchContents {
# Perform the check
my $sanityStatement = $sanityUI->check();
$badLSC = $sanityUI->lscIsBad();
$insane = $sanityUI->insane();

# This is the dispatcher; $action is the name of the action to perform,
# this is concatenated to _action to determine the name of the procedure.
# Dispatcher methods return a boolean to indicate whether to generate a
# link back to the main page at the end.
if ( $sanityUI->insane() || $query->param('abort') ) {

if ( $insane && $query->param('abort') ) {
print $sanityStatement;
}
else {
Expand All @@ -461,7 +464,7 @@ sub _dispatchContents {
die "Undefined action $action" unless defined(&$method);

no strict 'refs';
&$method();
&$method( $sanityStatement );
use strict 'refs';
}
}
Expand Down Expand Up @@ -710,11 +713,15 @@ sub _actionManageExtensions {
# This is the default screen
sub _actionConfigure {

# If coming from the save action, pick up the messages
my $saveMsgs = shift;
my $saveMsgs;
# If coming from the save action, or insane, pick up the messages
if ($insane) {
$saveMsgs = "<h1>INTERNAL ERROR - PROCEED WITH CAUTION</h1>";
}
$saveMsgs .= shift;

my $contents = '';
my $isFirstTime = $badLSC;
my $isFirstTime = $badLSC && !$insane;

#allow debugging of checker's guesses by showing the entire UI
$isFirstTime = 0 if ( $query->param('DEBUG') );
Expand Down
4 changes: 4 additions & 0 deletions core/lib/Foswiki/Configure/Checkers/BasicSanity.pm
Expand Up @@ -88,6 +88,7 @@ HERE
elsif ( -e $this->{LocalSiteDotCfg} ) {
eval { Foswiki::Configure::Load::readConfig(1); };
if ($@) {
$this->{errors}++;
$result .= <<HERE;
Existing configuration file has a problem
that is causing a Perl error - the following message(s) was generated:
Expand All @@ -98,6 +99,7 @@ HERE
$this->{badLSC} = 1;
}
elsif ( !-w $this->{LocalSiteDotCfg} ) {
$this->{errors}++;
$result .= <<HERE;
Cannot write to existing configuration file
$this->{LocalSiteDotCfg} is not writable.
Expand All @@ -106,6 +108,7 @@ Check the file permissions.
HERE
}
elsif ( ( my $mess = $this->_checkCfg( \%Foswiki::cfg ) ) ) {
$this->{errors}++;
$result .= <<HERE;
The existing configuration file
$this->{LocalSiteDotCfg} doesn't seem to contain a good configuration
Expand All @@ -123,6 +126,7 @@ HERE
my $errs = $this->checkCanCreateFile( $this->{LocalSiteDotCfg} );

if ($errs) {
$this->{errors}++;
$result .= <<HERE;
Configuration file $this->{LocalSiteDotCfg} does not exist, and I cannot
write a new configuration file due to these errors:
Expand Down

0 comments on commit 08d252e

Please sign in to comment.