From f721d43fd969e998dd7a14c918f43e328a170ee1 Mon Sep 17 00:00:00 2001 From: Marc Chantreux Date: Wed, 30 Jul 2008 13:27:57 +0200 Subject: [PATCH] C4::Context::import reloaded the problem was a context was stored every time C4::Context was called. Signed-off-by: Joshua Ferraro --- C4/Context.pm | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/C4/Context.pm b/C4/Context.pm index d2ceb426ef..7813f498a3 100644 --- a/C4/Context.pm +++ b/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 -- 2.20.1