FS/FS/Trace.pm
authorIvan Kohler <ivan@freeside.biz>
Fri, 3 Aug 2012 03:53:04 +0000 (20:53 -0700)
committerIvan Kohler <ivan@freeside.biz>
Fri, 3 Aug 2012 03:53:04 +0000 (20:53 -0700)
FS/FS/Mason/Request.pm
Makefile
htetc/handler.pl

index 0d21df4..36c46dc 100644 (file)
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use vars qw( $FSURL $QUERY_STRING );
 use base 'HTML::Mason::Request';
 use warnings;
 use vars qw( $FSURL $QUERY_STRING );
 use base 'HTML::Mason::Request';
+use FS::Trace;
 
 $FSURL = 'http://Set/FS_Mason_Request_FSURL/in_standalone_mode/';
 $QUERY_STRING = '';
 
 $FSURL = 'http://Set/FS_Mason_Request_FSURL/in_standalone_mode/';
 $QUERY_STRING = '';
@@ -11,21 +12,27 @@ $QUERY_STRING = '';
 sub new {
     my $class = shift;
 
 sub new {
     my $class = shift;
 
+    FS::Trace->log('creating new FS::Mason::Request object');
+
     my $superclass = $HTML::Mason::ApacheHandler::VERSION ?
                      'HTML::Mason::Request::ApacheHandler' :
                      $HTML::Mason::CGIHandler::VERSION ?
                      'HTML::Mason::Request::CGI' :
                      'HTML::Mason::Request';
 
     my $superclass = $HTML::Mason::ApacheHandler::VERSION ?
                      'HTML::Mason::Request::ApacheHandler' :
                      $HTML::Mason::CGIHandler::VERSION ?
                      'HTML::Mason::Request::CGI' :
                      'HTML::Mason::Request';
 
+    FS::Trace->log('  altering superclass');
     $class->alter_superclass( $superclass );
 
     $class->alter_superclass( $superclass );
 
+    FS::Trace->log('  setting valid params');
     #huh... shouldn't alter_superclass take care of this for us?
     __PACKAGE__->valid_params( %{ $superclass->valid_params() } );
 
     #huh... shouldn't alter_superclass take care of this for us?
     __PACKAGE__->valid_params( %{ $superclass->valid_params() } );
 
+    FS::Trace->log('  freeside_setup');
     my %opt = @_;
     my $mode = $superclass =~ /Apache/i ? 'apache' : 'standalone';
     $class->freeside_setup($opt{'comp'}, $mode);
 
     my %opt = @_;
     my $mode = $superclass =~ /Apache/i ? 'apache' : 'standalone';
     $class->freeside_setup($opt{'comp'}, $mode);
 
+    FS::Trace->log('  SUPER::new');
     $class->SUPER::new(@_);
 
 }
     $class->SUPER::new(@_);
 
 }
@@ -38,6 +45,8 @@ my $protect_fds;
 sub freeside_setup {
     my( $class, $filename, $mode ) = @_;
 
 sub freeside_setup {
     my( $class, $filename, $mode ) = @_;
 
+    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
     #from rt/bin/webmux.pl(.in)
     if ( !$protect_fds && $ENV{'MOD_PERL'} && exists $ENV{'MOD_PERL_API_VERSION'}
         && $ENV{'MOD_PERL_API_VERSION'} >= 2
@@ -57,6 +66,8 @@ sub freeside_setup {
 
     if ( $filename =~ qr(/REST/\d+\.\d+/NoAuth/) ) {
 
 
     if ( $filename =~ qr(/REST/\d+\.\d+/NoAuth/) ) {
 
+      FS::Trace->log('    handling RT REST/NoAuth file');
+
       package HTML::Mason::Commands; #?
       use FS::UID qw( adminsuidsetup );
 
       package HTML::Mason::Commands; #?
       use FS::UID qw( adminsuidsetup );
 
@@ -65,10 +76,13 @@ sub freeside_setup {
       ##old installs w/fs_selfs or selfserv??
       #&adminsuidsetup('fs_selfservice');
 
       ##old installs w/fs_selfs or selfserv??
       #&adminsuidsetup('fs_selfservice');
 
+      FS::Trace->log('    adminsuidsetup fs_queue');
       &adminsuidsetup('fs_queue');
 
     } else {
 
       &adminsuidsetup('fs_queue');
 
     } else {
 
+      FS::Trace->log('    handling regular file');
+
       package HTML::Mason::Commands;
       use vars qw( $cgi $p $fsurl ); # $lh ); #not using /mt
       use Encode;
       package HTML::Mason::Commands;
       use vars qw( $cgi $p $fsurl ); # $lh ); #not using /mt
       use Encode;
@@ -77,6 +91,7 @@ sub freeside_setup {
 
       if ( $mode eq 'apache' ) {
         $cgi = new CGI;
 
       if ( $mode eq 'apache' ) {
         $cgi = new CGI;
+        FS::Trace->log('    cgisuidsetup');
         &cgisuidsetup($cgi);
         #&cgisuidsetup($r);
         $fsurl = rooturl();
         &cgisuidsetup($cgi);
         #&cgisuidsetup($r);
         $fsurl = rooturl();
@@ -91,6 +106,7 @@ sub freeside_setup {
         die "unknown mode $mode";
       }
 
         die "unknown mode $mode";
       }
 
+    FS::Trace->log('    UTF-8-decoding form data');
     #
     foreach my $param ( $cgi->param ) {
       my @values = $cgi->param($param);
     #
     foreach my $param ( $cgi->param ) {
       my @values = $cgi->param($param);
@@ -102,6 +118,8 @@ sub freeside_setup {
     
   }
 
     
   }
 
+  FS::Trace->log('    done');
+
 }
 
 sub callback {
 }
 
 sub callback {
index 95ffbf2..864d9c2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -168,6 +168,11 @@ install-docs: check-conflicts docs
        cp -r masondocs ${FREESIDE_DOCUMENT_ROOT}
        chown -R freeside:freeside ${FREESIDE_DOCUMENT_ROOT}
        cp htetc/handler.pl ${MASON_HANDLER}
        cp -r masondocs ${FREESIDE_DOCUMENT_ROOT}
        chown -R freeside:freeside ${FREESIDE_DOCUMENT_ROOT}
        cp htetc/handler.pl ${MASON_HANDLER}
+       perl -p -i -e "\
+         s|%%%FREESIDE_EXPORT%%%|${FREESIDE_EXPORT}|g;\
+       " ${MASON_HANDLER} || true
+       mkdir -p ${FREESIDE_EXPORT}/profile
+       chown freeside ${FREESIDE_EXPORT}/profile
        cp htetc/htpasswd.logout ${FREESIDE_CONF}
        [ ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
        chown -R freeside ${MASONDATA}
        cp htetc/htpasswd.logout ${FREESIDE_CONF}
        [ ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
        chown -R freeside ${MASONDATA}
index cea3661..77b9346 100644 (file)
@@ -5,6 +5,7 @@ package HTML::Mason;
 use strict;
 use warnings;
 use FS::Mason qw( mason_interps );
 use strict;
 use warnings;
 use FS::Mason qw( mason_interps );
+use FS::Trace;
 
 #use vars qw($r);
 
 
 #use vars qw($r);
 
@@ -38,6 +39,8 @@ sub handler
     #($r) = @_;
     my $r = shift;
 
     #($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
     #from rt/bin/webmux.pl(.in)
     if ( !$protect_fds && $ENV{'MOD_PERL'} && exists $ENV{'MOD_PERL_API_VERSION'}
         && $ENV{'MOD_PERL_API_VERSION'} >= 2
@@ -63,6 +66,8 @@ sub handler
 
     ###Module::Refresh->refresh;###
 
 
     ###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
     $r->content_type('text/html; charset=utf-8');
     #$r->content_type('text/html; charset=iso-8859-1');
     #eorar
@@ -76,6 +81,8 @@ sub handler
 
     if ( $r->filename =~ /\/rt\// ) { #RT
 
 
     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;
       # 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;
@@ -84,15 +91,20 @@ sub handler
       local $SIG{__WARN__};
       local $SIG{__DIE__};
 
       local $SIG{__WARN__};
       local $SIG{__DIE__};
 
+      FS::Trace->log('initializing RT');
       my_rt_init();
 
       my_rt_init();
 
+      FS::Trace->log('setting RT interpreter');
       $ah->interp($rt_interp);
 
     } else {
 
       $ah->interp($rt_interp);
 
     } else {
 
+      FS::Trace->log('handling Freeside file');
+
       local $SIG{__WARN__};
       local $SIG{__DIE__};
 
       local $SIG{__WARN__};
       local $SIG{__DIE__};
 
+      FS::Trace->log('initializing RT');
       my_rt_init();
 
       #we don't want the RT error handlers under FS
       my_rt_init();
 
       #we don't want the RT error handlers under FS
@@ -102,10 +114,12 @@ sub handler
         undef($SIG{__DIE__})  if defined($SIG{__DIE__} );
       }
 
         undef($SIG{__DIE__})  if defined($SIG{__DIE__} );
       }
 
+      FS::Trace->log('setting Freeside interpreter');
       $ah->interp($fs_interp);
 
     }
 
       $ah->interp($fs_interp);
 
     }
 
+    FS::Trace->log('handling request');
     my %session;
     my $status;
     eval { $status = $ah->handle_request($r); };
     my %session;
     my $status;
     eval { $status = $ah->handle_request($r); };
@@ -125,6 +139,13 @@ sub handler
 #       );
 #    }
 
 #       );
 #    }
 
+    FS::Trace->log('done');
+
+    FS::Trace->dumpfile("%%%FREESIDE_EXPORT%%%/profile/$$.".time, $r->filename)
+      if FS::Trace->total > 5; #10?
+
+    FS::Trace->reset;
+
     $status;
 }
 
     $status;
 }