internal package
Foswiki::Configure::Load
Handling for loading configuration information (Foswiki.spec, Config.spec and
LocalSite.cfg) as efficiently and flexibly as possible.
This reads
values from these files and does
not parse the
structured comments or build a spec database. For that, see
LoadSpec.pm
StaticMethod
readConfig([$noexpand][,$nospec][,$config_spec][,$noLocal)
In normal Foswiki operations as a web server this method is called by the
BEGIN
block of
Foswiki.pm
. However, when benchmarking/debugging it can be
replaced by custom code which sets the configuration hash. To prevent us from
overriding the custom code again, we use an "unconfigurable" key
$cfg{ConfigurationFinished}
as an indicator.
Note that this method is called by Foswiki and configure, and normally reads
Foswiki.spec
to get defaults. Other spec files (those for extensions) are
not read unless the $config_spec flag is set.
The assumption is that
configure
will be run when an extension is installed,
and that will add the config values to
LocalSite.cfg, so no defaults are
needed. Foswiki.spec is still read because so much of the core code doesn't
provide defaults, and it would be silly to have them in two places anyway.
-
$noexpand
- suppress expansion of $Foswiki vars embedded in values.
-
$nospec
- can be set when the caller knows that Foswiki.spec has already been read.
-
$config_spec
- if set, will also read Config.spec files located using the standard methods (iff !$nospec). Slow.
-
$noLocal
- if set, Load will not re-read an existing LocalSite.cfg. this is needed when testing the bootstrap. If it rereads an existing config, it overlays all the bootstrapped settings.
StaticMethod
expanded($value) → $expanded
Given a value of a configuration item, expand references to
$Foswiki::cfg configuration items within strings in the value.
If an embedded $Foswiki::cfg reference is not defined, it will
be expanded as 'undef'.
StaticMethod
expandValue($datum [, $mode])
Expands references to Foswiki configuration items which occur in the
values configuration items contained within the datum, which may be a
hash or array reference, or a scalar value. The replacement is done in-place.
$mode - How to handle undefined values:
- false: 'undef' (string) is returned when an undefined value is encountered.
- 1 : return undef if any undefined value is encountered.
- 2 : return '' for any undefined value (including embedded)
- 3 : die if an undefined value is encountered.
StaticMethod
setBootstrap()
This routine is called to initialize the bootstrap process. It sets the list of
configuration parameters that will need to be set and "protected" during bootstrap.
If any keys will be set during bootstrap / initial creation of
LocalSite.cfg, they
should be added here so that they are preserved when the %Foswiki::cfg hash is
wiped and re-initialized from the Foswiki spec.
StaticMethod
bootstrapConfig()
This routine is called from Foswiki.pm BEGIN block to discover the mandatory
settings for operation when a
LocalSite.cfg could not be found.
StaticMethod
_bootstrapSiteSettings()
Called by bootstrapConfig. This handles the {Site} settings.
StaticMethod
_bootstrapStoreSettings()
Called by bootstrapConfig. This handles the store specific settings. This in turn
tests each Store Contib to determine if it's capable of bootstrapping.
StaticMethod
bootstrapWebSettings($script)
Called by bootstrapConfig. This handles the web environment specific settings only:
-
{DefaultUrlHost}
-
{ScriptUrlPath}
-
{ScriptUrlPaths}{view}
-
{PubUrlPath}
StaticMethod
findDependencies(\%cfg) → \%deps
-
\%cfg
configuration hash to scan; defaults to %Foswiki::cfg
Recursively locate references to other keys in the values of keys.
Returns a hash containing two keys:
-
forward
=> a hash mapping keys to a list of the keys that depend on their value
-
reverse
=> a hash mapping keys to a list of keys whose value they depend on.
StaticMethod
specChanged → @list
Find all the Spec files (Config.spec and Foswiki.spec) and return
a list of extensions with Spec files newer than
LocalSite.cfg.