Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item14237: Better support for extensions at early stages of the app l…
…ife.

- Config and extensions are now being loaded in a two-stage process
where first basic config class is used to initialize the config. Then
extensions are loaded. After that the process is repeated but at this
point the config could be loaded with a help of an extension.

- Added 'initStage' attribute to inidicate what is the current stage of
app initialization. Makes sense until contexts could be used.

- Added declaration of OOSPECS feature.

- Fixed a bug with deep recursion in create() method.
  • Loading branch information
vrurg committed May 6, 2017
1 parent e1b22ab commit 358b104
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
38 changes: 22 additions & 16 deletions core/lib/Foswiki/App.pm
Expand Up @@ -47,6 +47,11 @@ features_provided
PREF_SET_URLS => [ undef, undef, undef ],
PSGI => [ 2.99, undef, undef, -desc => 'PSGI support', ],
UNICODE => [ 2.0, undef, undef, -desc => 'Unicode core', ],
OOSPECS => [
2.99, undef, undef,
-desc => "Perl Specs",
-proposal => "OOConfigSpecsFormat",
],
;

has access => (
Expand Down Expand Up @@ -114,6 +119,7 @@ has extensions => (
is => 'ro',
lazy => 1,
predicate => 1,
clearer => 1,
builder => 'prepareExtensions',
);
has forms => (
Expand Down Expand Up @@ -345,22 +351,17 @@ sub BUILD {

$Foswiki::app = $this;

$this->initStage('initConfig');

unless ( $this->cfg->data->{isVALID} ) {
$this->cfg->bootstrapSystemSettings;
}

$this->initStage('extLoad');

$this->extensions->initialize;

$this->clear_cfg;

$this->initStage('reConfig');
for my $stNum ( 1 .. 2 ) {
$this->clear_cfg;
$this->initStage( 'readConfig' . $stNum );
unless ( $this->cfg->data->{isVALID} ) {
$this->cfg->bootstrapSystemSettings;
}
$this->initStage( 'loadExtensions' . $stNum );

unless ( $this->cfg->data->{isVALID} ) {
$this->cfg->bootstrapSystemSettings;
# Reload extensions based on the configuration information.
$this->clear_extensions;
$this->extensions->initialize;
}

$this->initStage('postConfig');
Expand Down Expand Up @@ -658,7 +659,12 @@ sub create {

Foswiki::load_class($class);

$class = $this->extensions->mapClass($class);
if ( $this->has_extensions ) {

# Avoid referring to extensions if we're on very early stages of the app
# existance.
$class = $this->extensions->mapClass($class);
}

my $object;

Expand Down
6 changes: 2 additions & 4 deletions core/lib/Foswiki/Config.pm
Expand Up @@ -297,9 +297,7 @@ has _lscRecords => (
);

# Current position in _lscRecords list.
has _lscRecPos => (
is => 'rw',
);
has _lscRecPos => ( is => 'rw', );

# Configuration shortcut attributes.

Expand Down Expand Up @@ -772,7 +770,7 @@ pluggable read => sub {

# SMELL Docs missing
pluggable readLSCStart => sub {
my $this = shift;
my $this = shift;
my %params = @_;

$this->_clear_lscRecords;
Expand Down

0 comments on commit 358b104

Please sign in to comment.