From e46c68251a55936a943e89c4fa6c3be7beff3f05 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 29 Dec 2010 17:27:10 +0100 Subject: [PATCH] Fehler im Bootstrapping besser handhaben. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Konkret, wenn config/authentication.pl nicht richtig geladen wird. Fix für Bug 1472. --- SL/Auth.pm | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/SL/Auth.pm b/SL/Auth.pm index 6bb7bfaa7..c573c3060 100644 --- a/SL/Auth.pm +++ b/SL/Auth.pm @@ -59,19 +59,31 @@ sub DESTROY { $self->{dbh}->disconnect() if ($self->{dbh}); } +# form isn't loaded yet, so auth needs it's own error. +sub mini_error { + $::lxdebug->show_backtrace(); + + my ($self, @msg) = @_; + if ($ENV{HTTP_USER_AGENT}) { + print Form->create_http_response(content_type => 'text/html'); + print "
", join ('
', @msg), "
"; + } else { + print STDERR "Error: @msg\n"; + } + ::end_of_request(); +} + sub _read_auth_config { $main::lxdebug->enter_sub(); my $self = shift; - my $form = $main::form; - my $locale = $main::locale; - my $code; my $in = IO::File->new('config/authentication.pl', 'r'); if (!$in) { - $form->error($locale->text('The config file "config/authentication.pl" was not found.')); + my $locale = Locale->new('en'); + $self->mini_error($locale->text('The config file "config/authentication.pl" was not found.')); } while (<$in>) { @@ -82,7 +94,8 @@ sub _read_auth_config { eval $code; if ($@) { - $form->error($locale->text('The config file "config/authentication.pl" contained invalid Perl code:') . "\n" . $@); + my $locale = Locale->new('en'); + $self->mini_error($locale->text('The config file "config/authentication.pl" contained invalid Perl code:'), $@); } if ($self->{module} eq 'DB') { @@ -93,17 +106,20 @@ sub _read_auth_config { } if (!$self->{authenticator}) { - $form->error($locale->text('No or an unknown authenticantion module specified in "config/authentication.pl".')); + my $locale = Locale->new('en'); + $self->mini_error($locale->text('No or an unknown authenticantion module specified in "config/authentication.pl".')); } my $cfg = $self->{DB_config}; if (!$cfg) { - $form->error($locale->text('config/authentication.pl: Key "DB_config" is missing.')); + my $locale = Locale->new('en'); + $self->mini_error($locale->text('config/authentication.pl: Key "DB_config" is missing.')); } if (!$cfg->{host} || !$cfg->{db} || !$cfg->{user}) { - $form->error($locale->text('config/authentication.pl: Missing parameters in "DB_config". Required parameters are "host", "db" and "user".')); + my $locale = Locale->new('en'); + $self->mini_error($locale->text('config/authentication.pl: Missing parameters in "DB_config". Required parameters are "host", "db" and "user".')); } $self->{authenticator}->verify_config(); -- 2.20.1