From 18a9b190c4f03ff02bfc5eae1fc253116cabe02f Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 13 Jan 2011 10:28:23 +0100 Subject: [PATCH] =?utf8?q?Fix=20f=C3=BCr:=20Datenbankverbindungen=20bei=20?= =?utf8?q?identischen=20Verbindungseinstellungen=20nur=20einmal=20bei=20Ro?= =?utf8?q?se=20registrieren?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB.pm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/SL/DB.pm b/SL/DB.pm index bcbf2e146..4a78738c2 100644 --- a/SL/DB.pm +++ b/SL/DB.pm @@ -54,8 +54,10 @@ sub _register_db { }); } + my %flattened_settings = _flatten_settings(%connect_settings); + $domain = 'LXOFFICE' if $type =~ m/^LXOFFICE/; - $type .= join($SUBSCRIPT_SEPARATOR, map { $::connect_setings{$_} } sort keys %connect_settings); + $type .= join($SUBSCRIPT_SEPARATOR, map { ($_, $flattened_settings{$_}) } sort keys %flattened_settings); my $idx = "${domain}::${type}"; if (!$_db_registered{$idx}) { @@ -70,4 +72,19 @@ sub _register_db { return ($domain, $type); } +sub _flatten_settings { + my %settings = @_; + my %flattened = (); + + while (my ($key, $value) = each %settings) { + if ('HASH' eq ref $value) { + %flattened = ( %flattened, _flatten_settings(%{ $value }) ); + } else { + $flattened{$key} = $value; + } + } + + return %flattened; +} + 1; -- 2.20.1