merging RT 4.0.6
[freeside.git] / rt / lib / RT.pm
index ec2e6cc..063f7f7 100644 (file)
@@ -138,8 +138,6 @@ up logging|/InitLogging>, and L<loads plugins|/InitPlugins>.
 
 sub Init {
 
-    my @arg = @_;
-
     CheckPerlRequirements();
 
     InitPluginPaths();
@@ -148,7 +146,7 @@ sub Init {
     ConnectToDatabase();
     InitSystemObjects();
     InitClasses();
-    InitLogging(@arg);
+    InitLogging();
     InitPlugins();
     RT::I18N->Init;
     RT->Config->PostLoadCheck;
@@ -176,8 +174,6 @@ Create the Logger object and set up signal handlers.
 
 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.
@@ -313,45 +309,39 @@ sub InitLogging {
                          ));
         }
     }
-    InitSignalHandlers(%arg);
+    InitSignalHandlers();
 }
 
 sub InitSignalHandlers {
 
-    my %arg = @_;
-
 # Signal handlers
 ## This is the default handling of warnings and die'ings in the code
 ## (including other used modules - maybe except for errors catched by
 ## 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
-            # unicode strings.
-            # use 'goto &foo' syntax to hide ANON sub from stack
-            if( index($_[0], 'Wide character in ') != 0 ) {
-                unshift @_, $RT::Logger, qw(level warning message);
-                goto &Log::Dispatch::log;
-            }
-        };
+    $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
+        # unicode strings.
+        # use 'goto &foo' syntax to hide ANON sub from stack
+        if( index($_[0], 'Wide character in ') != 0 ) {
+            unshift @_, $RT::Logger, qw(level warning message);
+            goto &Log::Dispatch::log;
+        }
+    };
 
-        #When we call die, trap it and log->crit with the value of the die.
+#When we call die, trap it and log->crit with the value of the die.
 
-        $SIG{__DIE__}  = sub {
-            # if we are not in eval and perl is not parsing code
-            # then rollback transactions and log RT error
-            unless ($^S || !defined $^S ) {
-                $RT::Handle->Rollback(1) if $RT::Handle;
-                $RT::Logger->crit("$_[0]") if $RT::Logger;
-            }
-            die $_[0];
-        };
-
-    }
+    $SIG{__DIE__}  = sub {
+        # if we are not in eval and perl is not parsing code
+        # then rollback transactions and log RT error
+        unless ($^S || !defined $^S ) {
+            $RT::Handle->Rollback(1) if $RT::Handle;
+            $RT::Logger->crit("$_[0]") if $RT::Logger;
+        }
+        die $_[0];
+    };
 }
 
 
@@ -425,6 +415,7 @@ sub InitClasses {
     require RT::Approval;
     require RT::Lifecycle;
     require RT::Link;
+    require RT::Links;
     require RT::Article;
     require RT::Articles;
     require RT::Class;
@@ -688,11 +679,21 @@ sub InitPlugins {
 sub InstallMode {
     my $self = shift;
     if (@_) {
-         $_INSTALL_MODE = shift;
-         if($_INSTALL_MODE) {
-             require RT::CurrentUser;
-            $SystemUser = RT::CurrentUser->new();
-         }
+        my ($integrity, $state, $msg) = RT::Handle->CheckIntegrity;
+        if ($_[0] and $integrity) {
+            # Trying to turn install mode on but we have a good DB!
+            require Carp;
+            $RT::Logger->error(
+                Carp::longmess("Something tried to turn on InstallMode but we have DB integrity!")
+            );
+        }
+        else {
+            $_INSTALL_MODE = shift;
+            if($_INSTALL_MODE) {
+                require RT::CurrentUser;
+               $SystemUser = RT::CurrentUser->new();
+            }
+        }
     }
     return $_INSTALL_MODE;
 }
@@ -745,7 +746,7 @@ sub CanonicalizeGeneratedPaths {
 =head2 AddJavaScript
 
 helper method to add js files to C<JSFiles> config.
-to add extra css files, you can add the following line
+to add extra js files, you can add the following line
 in the plugin's main file:
 
     RT->AddJavaScript( 'foo.js', 'bar.js' );