use strict;
use warnings;
use FS::Mason qw( mason_interps );
+use FS::Trace;
+
+if ( %%%RT_ENABLED%%% ) {
+
+ require RT;
+
+ $> = scalar(getpwnam('freeside'));
+
+ RT::LoadConfig();
+ RT::Init();
+
+ # disconnect DB before fork:
+ # (avoid 'prepared statement "dbdpg_p\d+_\d+" already exists' errors?)
+ $RT::Handle->dbh(undef);
+ undef $RT::Handle;
+
+ $> = $<;
+}
#use vars qw($r);
#($r) = @_;
my $r = shift;
+ FS::Trace->log('protecting fds');
+
#from rt/bin/webmux.pl(.in)
if ( !$protect_fds && $ENV{'MOD_PERL'} && exists $ENV{'MOD_PERL_API_VERSION'}
&& $ENV{'MOD_PERL_API_VERSION'} >= 2
###Module::Refresh->refresh;###
+ FS::Trace->log('setting content_type / headers');
+
$r->content_type('text/html; charset=utf-8');
#$r->content_type('text/html; charset=iso-8859-1');
#eorar
if ( $r->filename =~ /\/rt\// ) { #RT
+ FS::Trace->log('handling RT file');
+
# We don't need to handle non-text, non-xml items
return -1 if defined( $r->content_type )
&& $r->content_type !~ m!(^text/|\bxml\b)!io;
local $SIG{__WARN__};
local $SIG{__DIE__};
- RT::Init();
+ FS::Trace->log('initializing RT');
+ my_rt_init();
+ FS::Trace->log('setting RT interpreter');
$ah->interp($rt_interp);
} else {
+ FS::Trace->log('handling Freeside file');
+
local $SIG{__WARN__};
local $SIG{__DIE__};
- RT::Init() if $RT::VERSION; #for lack of something else
+ FS::Trace->log('initializing RT');
+ my_rt_init();
#we don't want the RT error handlers under FS
{
undef($SIG{__DIE__}) if defined($SIG{__DIE__} );
}
+ FS::Trace->log('setting Freeside interpreter');
$ah->interp($fs_interp);
}
+ FS::Trace->log('handling request');
my %session;
my $status;
eval { $status = $ah->handle_request($r); };
# );
# }
+ FS::Trace->log('done');
+
+ FS::Trace->dumpfile( "%%%FREESIDE_EXPORT%%%/profile/$$.".time,
+ FS::Trace->total. ' '. $r->filename
+ )
+ if FS::Trace->total > 5; #10?
+
+ FS::Trace->reset;
+
$status;
}
+sub my_rt_init {
+ return unless $RT::VERSION;
+ RT::ConnectToDatabase();
+ RT::InitSignalHandlers();
+}
+
1;