Browse Source

C4::Context::import reloaded

the problem was a context was stored every time C4::Context was called.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
3.0.x
Marc Chantreux 16 years ago
committed by Joshua Ferraro
parent
commit
f721d43fd9
  1. 23
      C4/Context.pm

23
C4/Context.pm

@ -254,14 +254,21 @@ sub db_scheme2dbi {
}
sub import {
my $package = shift;
my $conf_fname = shift; # Config file name
# Create a new context from the given config file name, if
# any, then set it as the current context.
$context = new C4::Context($conf_fname) unless $context;
return undef if !defined($context);
$context->set_context;
# Create the default context ($C4::Context::Context)
# the first time the module is called
# (a config file can be optionaly passed)
# default context allready exists?
return if $context;
# no ? so load it!
my ($pkg,$config_file) = @_ ;
my $new_ctx = __PACKAGE__->new($config_file);
return unless $new_ctx;
# if successfully loaded, use it by default
$new_ctx->set_context;
1;
}
=item new

Loading…
Cancel
Save