From 23f79a876613fabf7f4aa2de230788ebeb840de9 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 3 Jan 2011 14:30:34 +0100 Subject: [PATCH] Umstellung des Dispatcher-Moduls auf Objekt-Aufrufsyntax --- SL/Dispatcher.pm | 17 ++++++++++++++--- admin.pl | 5 +++-- dispatcher.fpl | 6 ++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/SL/Dispatcher.pm b/SL/Dispatcher.pm index cc886d8ca..e6aa54774 100644 --- a/SL/Dispatcher.pm +++ b/SL/Dispatcher.pm @@ -22,6 +22,15 @@ use File::Basename; # number 'die' was called in. use constant END_OF_REQUEST => "END-OF-REQUEST\n"; +sub new { + my ($class, $interface) = @_; + + my $self = bless {}, $class; + $self->{interface} = lc($interface || 'cgi'); + + return $self; +} + sub pre_request_checks { if (!$::auth->session_tables_present) { if ($::form->{script} eq 'admin.pl') { @@ -138,15 +147,16 @@ sub _run_controller { } sub handle_request { + my $self = shift; + $::lxdebug->enter_sub; $::lxdebug->begin_request; - my $interface = lc(shift || 'cgi'); my ($script, $path, $suffix, $script_name, $action, $routing_type); $script_name = $ENV{SCRIPT_NAME}; - unrequire_bin_mozilla($interface); + $self->unrequire_bin_mozilla; $::cgi = CGI->new(''); $::locale = Locale->new($::language); @@ -230,7 +240,8 @@ sub handle_request { } sub unrequire_bin_mozilla { - return unless $_[0] =~ m/^(?:fastcgi|fcgid|fcgi)$/; + my $self = shift; + return unless $self->{interface} =~ m/^(?:fastcgi|fcgid|fcgi)$/; for (keys %INC) { next unless m#^bin/mozilla/#; diff --git a/admin.pl b/admin.pl index 603d166b2..60c4ff206 100755 --- a/admin.pl +++ b/admin.pl @@ -4,7 +4,8 @@ use strict; use SL::Dispatcher; -SL::Dispatcher::pre_startup(); -SL::Dispatcher::handle_request('CGI'); +my $dispatcher = SL::Dispatcher->new('CGI'); +$dispatcher->pre_startup; +$dispatcher->handle_request; 1; diff --git a/dispatcher.fpl b/dispatcher.fpl index afe1bc6ed..e5c8ca9dd 100755 --- a/dispatcher.fpl +++ b/dispatcher.fpl @@ -8,8 +8,10 @@ use SL::FCGIFixes; SL::FCGIFixes::apply_fixes(); -SL::Dispatcher::pre_startup(); +my $dispatcher = SL::Dispatcher->new('FastCGI'); +$dispatcher->pre_startup; + my $request = FCGI::Request(); -SL::Dispatcher::handle_request('FastCGI') while $request->Accept() >= 0; +$dispatcher->handle_request($request) while $request->Accept() >= 0; 1; -- 2.20.1