not changing this hopefully will cause fewer upgrade conflicts. stupid BPS header
[freeside.git] / rt / lib / RT.pm
index 0d0c0f5..c2040d5 100644 (file)
@@ -2,7 +2,7 @@
 # 
 # COPYRIGHT:
 #  
-# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC 
+# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC 
 #                                          <jesse@bestpractical.com>
 # 
 # (Except where explicitly superseded by other copyright notices)
@@ -68,7 +68,7 @@ use vars qw($VERSION $System $SystemUser $Nobody $Handle $Logger
         $MasonSessionDir
 );
 
-$VERSION = '3.6.4';
+$VERSION = '3.6.6';
 $CORE_CONFIG_FILE = "/opt/rt3/etc/RT_Config.pm";
 $SITE_CONFIG_FILE = "/opt/rt3/etc/RT_SiteConfig.pm";
 
@@ -161,12 +161,12 @@ EOF
     }
     eval { require $CORE_CONFIG_FILE };
     if ($@) {
-        my ($fileuid,$filegid) = (stat($SITE_CONFIG_FILE))[4,5];
+        my ($fileuid,$filegid) = (stat($CORE_CONFIG_FILE))[4,5];
         my $fileusername = getpwuid($fileuid);
         my $filegroup = getgrgid($filegid);
-        my $errormessage = sprintf($message, $SITE_CONFIG_FILE,
+        my $errormessage = sprintf($message, $CORE_CONFIG_FILE,
                                    $fileusername, $filegroup, $filegroup);
-        die ("$errormessage '$CORE_CONFIG_FILE'\n$@") 
+        die ("$errormessage\n$@") 
     }
 
     # RT::Essentials mistakenly recommends that WebPath be set to '/'.
@@ -186,6 +186,8 @@ Conenct to the database, set up logging.
 
 sub Init {
 
+    my @arg = @_;
+
     CheckPerlRequirements();
 
     #Get a database connection
@@ -202,7 +204,7 @@ sub Init {
     $System = RT::System->new();
 
     InitClasses();
-    InitLogging(); 
+    InitLogging(@arg); 
 }
 
 
@@ -228,6 +230,8 @@ Create the RT::Logger object.
 
 sub InitLogging {
 
+    my %arg = @_;
+
     # We have to set the record separator ($, man perlvar)
     # or Log::Dispatch starts getting
     # really pissy, as some other module we use unsets it.
@@ -342,6 +346,8 @@ sub InitLogging {
 ## Mason).  It will log all problems through the standard logging
 ## mechanism (see above).
 
+    unless ( $arg{'NoSignalHandlers'} ) {
+
     $SIG{__WARN__} = sub {
         # The 'wide character' warnings has to be silenced for now, at least
         # until HTML::Mason offers a sane way to process both raw output and
@@ -363,6 +369,8 @@ $SIG{__DIE__}  = sub {
     die $_[0];
 };
 
+    }
+
 # }}}
 
 }
@@ -410,7 +418,9 @@ Load all modules that define base classes
 sub InitClasses {
     require RT::Tickets;
     require RT::Transactions;
+    require RT::Attachments;
     require RT::Users;
+    require RT::Principals;
     require RT::CurrentUser;
     require RT::Templates;
     require RT::Queues;
@@ -423,6 +433,31 @@ sub InitClasses {
     require RT::CustomFieldValues;
     require RT::ObjectCustomFields;
     require RT::ObjectCustomFieldValues;
+    require RT::Attributes;
+
+    # on a cold server (just after restart) people could have an object
+    # in the session, as we deserialize it so we never call constructor
+    # of the class, so the list of accessible fields is empty and we die
+    # with "Method xxx is not implemented in RT::SomeClass"
+    $_->_BuildTableAttributes foreach qw(
+        RT::Ticket
+        RT::Transaction
+        RT::Attachment
+        RT::User
+        RT::Principal
+        RT::Template
+        RT::Queue
+        RT::ScripAction
+        RT::ScripCondition
+        RT::Scrip
+        RT::Group
+        RT::GroupMember
+        RT::CustomField
+        RT::CustomFieldValue
+        RT::ObjectCustomField
+        RT::ObjectCustomFieldValue
+        RT::Attribute
+    );
 }
 
 # }}}
@@ -459,6 +494,8 @@ ok ($RT::SystemUser->Name() ne 'noname', "The system user isn't noname");
 
 =cut
 
+eval "require RT_Vendor";
+die $@ if ($@ && $@ !~ qr{^Can't locate RT_Vendor.pm});
 eval "require RT_Local";
 die $@ if ($@ && $@ !~ qr{^Can't locate RT_Local.pm});