Skip to content

Commit ffa59a9

Browse files
committed
Item13079: Fix initial configuration from shell
1 parent bba8fec commit ffa59a9

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

core/lib/Foswiki/Configure/Load.pm

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ our $ITEMREGEX = qr/(?:\{(?:'(?:\\.|[^'])+'|"(?:\\.|[^"])+"|[A-Za-z0-9_]+)\})+/;
3232
our $TRUE = 1;
3333
our $FALSE = 0;
3434

35-
# Bootstrap works out the correct values of these keys
36-
my @BOOTSTRAP =
37-
qw( {DataDir} {DefaultUrlHost} {PubUrlPath} {ToolsDir} {WorkingDir}
38-
{PubDir} {TemplateDir} {ScriptDir} {ScriptUrlPath} {ScriptUrlPaths}{view} {ScriptSuffix} {LocalesDir} );
39-
4035
# Configuration items that have been deprecated and must be mapped to
4136
# new configuration items. The value is mapped unchanged.
4237
our %remap = (
@@ -306,6 +301,30 @@ sub _handleExpand {
306301

307302
=begin TML
308303
304+
---++ StaticMethod setBootstrap()
305+
306+
This routine is called to initialize the bootstrap process. It sets the list of
307+
configuration parameters that will need to be set and "protected" during bootstrap.
308+
309+
If any keys will be set during bootstrap / initial creation of LocalSite.cfg, they
310+
should be added here so that they are preserved when the %Foswiki::cfg hash is
311+
wiped and re-initialized from the Foswiki spec.
312+
313+
=cut
314+
315+
sub setBootstrap {
316+
317+
# Bootstrap works out the correct values of these keys
318+
my @BOOTSTRAP =
319+
qw( {DataDir} {DefaultUrlHost} {PubUrlPath} {ToolsDir} {WorkingDir}
320+
{PubDir} {TemplateDir} {ScriptDir} {ScriptUrlPath} {ScriptUrlPaths}{view} {ScriptSuffix} {LocalesDir} );
321+
322+
$Foswiki::cfg{isBOOTSTRAPPING} = 1;
323+
push( @{ $Foswiki::cfg{BOOTSTRAP} }, @BOOTSTRAP );
324+
}
325+
326+
=begin TML
327+
309328
---++ StaticMethod bootstrapConfig( $noload )
310329
311330
This routine is called from Foswiki.pm BEGIN block to discover the mandatory
@@ -564,9 +583,8 @@ EPITAPH
564583

565584
_workOutOS();
566585

567-
$Foswiki::cfg{isVALID} = 1;
568-
$Foswiki::cfg{isBOOTSTRAPPING} = 1;
569-
push( @{ $Foswiki::cfg{BOOTSTRAP} }, @BOOTSTRAP );
586+
$Foswiki::cfg{isVALID} = 1;
587+
Foswiki::Configure::Load::setBootstrap();
570588
eval 'require Foswiki::Plugins::ConfigurePlugin';
571589
die
572590
"LocalSite.cfg load failed, and ConfigurePlugin could not be loaded: $@"
@@ -596,7 +614,7 @@ BOOTS
596614
597615
---++ StaticMethod findDependencies(\%cfg) -> \%deps
598616
599-
* =\%cfg= configuration hash to scan; defaults to %Foswiki::cfg
617+
* =\%cfg= configuration hash to scan; defaults to %Foswiki::cfg
600618
601619
Recursively locate references to other keys in the values of keys.
602620
Returns a hash containing two keys:

core/tools/configure

100644100755
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,22 +197,23 @@ unless ( $Foswiki::cfg{isVALID} ) {
197197
%Foswiki::cfg = ();
198198
print STDERR "LocalSite.cfg load failed\n"
199199
. Foswiki::Configure::Reporter::stripStacktrace($@);
200+
Foswiki::Configure::Load::readConfig( 0, 0, 1 );
200201
print "** Enter values for critical configuration items.\n";
201202
print
202203
"** type a new value or hit return to accept the value in brackets.\n";
203204
_prompt( $root, '{DefaultUrlHost}', 'http://localhost' );
204-
_prompt( $root, '{ScriptUrlPath}' );
205-
_prompt( $root, '{PubUrlPath}' );
205+
_prompt( $root, '{ScriptUrlPath}', '/foswiki/bin' );
206+
_prompt( $root, '{PubUrlPath}', '/foswiki/pub' );
206207
_prompt( $root, '{ScriptDir}', "$bin/../bin" );
207-
_prompt( $root, '{DataDir}', "$bin/../pub" );
208+
_prompt( $root, '{DataDir}', "$bin/../data" );
208209
_prompt( $root, '{PubDir}', "$bin/../pub" );
209210
_prompt( $root, '{TemplateDir}', "$bin/../templates" );
210211
_prompt( $root, '{LocalesDir}', "$bin/../locale" );
211212
_prompt( $root, '{WorkingDir}', "$bin/../working" );
212213
_prompt( $root, '{ToolsDir}', $bin );
213-
Foswiki::Configure::Load::readConfig( 0, 0, 1 );
214-
$Foswiki::cfg{isVALID} = 1;
215-
$Foswiki::cfg{isBOOTSTRAPPING} = 1;
214+
215+
Foswiki::Configure::Load::setBootstrap();
216+
$Foswiki::cfg{isVALID} = 1;
216217
}
217218

218219
if ( $reporter->has_level('errors') ) {

0 commit comments

Comments
 (0)