X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fbin%2Fwebmux.pl.in;h=7e61b277506f9f140a271fdd94f434b374ec69ad;hb=b5bb1a07a26d5666cb059b5299a6ca2883f2153a;hp=4cc4d6128a49070202c76fc5872c515a2be32567;hpb=5e05724a635a22776f1b973f5d7e77989da4e048;p=freeside.git diff --git a/rt/bin/webmux.pl.in b/rt/bin/webmux.pl.in index 4cc4d6128..7e61b2775 100644 --- a/rt/bin/webmux.pl.in +++ b/rt/bin/webmux.pl.in @@ -2,8 +2,8 @@ # BEGIN BPS TAGGED BLOCK {{{ # # COPYRIGHT: -# -# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC +# +# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -23,7 +23,9 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301 or visit their web page on the internet at +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. # # # CONTRIBUTION SUBMISSION POLICY: @@ -62,7 +64,30 @@ BEGIN { } -use lib ( "@LOCAL_LIB_PATH@", "@RT_LIB_PATH@" ); +# fix lib paths, some may be relative +BEGIN { + require File::Spec; + my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@"); + my $bin_path; + + for my $lib (@libs) { + unless ( File::Spec->file_name_is_absolute($lib) ) { + unless ($bin_path) { + if ( File::Spec->file_name_is_absolute(__FILE__) ) { + $bin_path = ( File::Spec->splitpath(__FILE__) )[1]; + } + else { + require FindBin; + no warnings "once"; + $bin_path = $FindBin::Bin; + } + } + $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib ); + } + unshift @INC, $lib; + } + +} use RT; package RT::Mason; @@ -72,21 +97,35 @@ use vars qw($Nobody $SystemUser $Handler $r); #This drags in RT's config.pm BEGIN { RT::LoadConfig(); - if ($RT::DevelMode) { require Module::Refresh; } + if (RT->Config->Get('DevelMode')) { require Module::Refresh; } + RT->InitPluginPaths(); } - { + require RT::Handle; + my $dsn = RT::Handle->DSN; + my $user = RT->Config->Get('DatabaseUser'); + my $pass = RT->Config->Get('DatabasePassword'); + + my $dbh = DBI->connect( + $dsn, $user, $pass, + { RaiseError => 0, PrintError => 0 }, + ); + if ( $dbh ) { + my ($status, $msg) = RT::Handle->CheckCompatibility( $dbh, 'post' ); + die $msg unless $status; + } +} +{ package HTML::Mason::Commands; use vars qw(%session); } use RT::Interface::Web; use RT::Interface::Web::Handler; -$Handler = RT::Interface::Web::Handler->new(@RT::MasonParameters); -if ($ENV{'MOD_PERL'} && !$RT::DevelMode) { +if ($ENV{'MOD_PERL'} && !RT->Config->Get('DevelMode')) { # Under static_source, we need to purge the component cache # each time we restart, so newer components may be reloaded. # @@ -105,20 +144,23 @@ sub handler { local $SIG{__WARN__}; local $SIG{__DIE__}; - # We don't need to handle non-text, non-xml items if ($r->content_type =~ m/^httpd\b.*\bdirectory/i) { use File::Spec::Unix; # Our DirectoryIndex is always index.html, regardless of httpd settings $r->filename( File::Spec::Unix->catfile( $r->filename, 'index.html' ) ); } - elsif (defined( $r->content_type )) { - $r->content_type =~ m!(^text/|\bxml\b)!i or return -1; - } +# elsif (defined( $r->content_type )) { + #$r->content_type !~ m!(^text/|\bxml\b)!i or return -1; +# } - Module::Refresh->refresh if $RT::DevelMode; + Module::Refresh->refresh if RT->Config->Get('DevelMode'); RT::Init(); + $Handler ||= RT::Interface::Web::Handler->new( + RT->Config->Get('MasonParameters') + ); + my %session; my $status; eval { $status = $Handler->handle_request($r) };