From e476a9df6d7b8794add9fe384a624817dc21c21b Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 10 Feb 2017 15:02:34 +0100 Subject: [PATCH] Auth-DB-Spalten-Infos nur lesen, wenn DB-Verbindung vorhanden MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit »reset« wird während des Request-Shutdowns ausgeführt. Falls aber noch gar keine Auth-DB existiert (neue Installation z.B.), so wird versucht, eine Verbindung dahin aufzubauen, was zu einer Fehlermeldung führt — selbst, wenn man gerade versucht, besagte Auth-DB anzulegen. --- SL/Auth.pm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/SL/Auth.pm b/SL/Auth.pm index e8d6c72e1..c2e6f7336 100644 --- a/SL/Auth.pm +++ b/SL/Auth.pm @@ -59,8 +59,19 @@ sub reset { $self->{FULL_RIGHTS} = { }; $self->{RIGHTS} = { }; $self->{unique_counter} = 0; - $self->{column_information} = SL::Auth::ColumnInformation->new(auth => $self); - $self->{column_information}->_fetch; + + if ($self->is_db_connected) { + # reset is called during request shutdown already. In case of a + # completely new auth DB this would fail and generate an error + # message even if the user is currently trying to create said auth + # DB. Therefore only fetch the column information if a connection + # has been established. + $self->{column_information} = SL::Auth::ColumnInformation->new(auth => $self); + $self->{column_information}->_fetch; + } else { + delete $self->{column_information}; + } + $self->{authenticator}->reset; $self->client(undef); @@ -247,6 +258,7 @@ sub dbconnect { $self->{dbh} = SL::DBConnect->connect($dsn, $cfg->{user}, $cfg->{password}, { pg_enable_utf8 => 1, AutoCommit => 1 }); if (!$may_fail && !$self->{dbh}) { + delete $self->{dbh}; $main::form->error($main::locale->text('The connection to the authentication database failed:') . "\n" . $DBI::errstr); } @@ -262,6 +274,11 @@ sub dbdisconnect { } } +sub is_db_connected { + my ($self) = @_; + return !!$self->{dbh}; +} + sub check_tables { my ($self, $dbh) = @_; -- 2.20.1