diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/RESTServer.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/RESTServer.pm index 7a83ff69e..70655ab22 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/RESTServer.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/RESTServer.pm @@ -71,17 +71,9 @@ sub getConfByNum { unless ( %{ $self->currentConf } and $cfgNum == $self->currentConf->{cfgNum} ) { - my $tmp; - if ( $cfgNum == 0 ) { - require Lemonldap::NG::Manager::Conf::Zero; - $tmp = Lemonldap::NG::Manager::Conf::Zero::zeroConf(); - } - else { - $tmp = - $self->confAcc->getConf( - { cfgNum => $cfgNum, raw => 1, noCache => 1, @args } ); - return undef unless ( $tmp and ref($tmp) and %$tmp ); - } + my $tmp = $self->confAcc->getConf( + { cfgNum => $cfgNum, raw => 1, noCache => 1, @args } ); + return undef unless ( $tmp and ref($tmp) and %$tmp ); $self->currentConf($tmp); } return $cfgNum; diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf.pm index 006493a5d..b1fccefc4 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf.pm @@ -146,12 +146,32 @@ sub prx { # IV. Upload methods # ###################### -# In this section, 3 methods: +# In this section, 4 methods: +# - getConfByNum: override SUPER method to be able to use Zero # - newConf() # - newRawConf(): restore a saved conf # - applyConf(): called by the 2 previous to prevent other servers that a new # configuration is available +sub getConfByNum { + my ( $self, $cfgNum, @args ) = @_; + unless ( %{ $self->currentConf } + and $cfgNum == $self->currentConf->{cfgNum} ) + { + my $tmp; + if ( $cfgNum == 0 ) { + require Lemonldap::NG::Manager::Conf::Zero; + $tmp = Lemonldap::NG::Manager::Conf::Zero::zeroConf(); + $self->currentConf($tmp); + } + else { + $tmp = $self->SUPER::getConfByNum( $cfgNum, @args ); + return undef unless (defined $tmp); + } + } + return $cfgNum; +} + ## @method PSGI-JSON-response newConf($req) # Call Lemonldap::NG::Manager::Conf::Parser to parse new configuration and store # it