[Rt-commit] rt branch, 4.0/web-installer-tests, updated. rt-4.0.4-179-g80e6a7c

Thomas Sibley trs at bestpractical.com
Wed Jan 18 13:16:20 EST 2012


The branch, 4.0/web-installer-tests has been updated
       via  80e6a7c4210c5339fdbb0c0d5e76cbc20f9416bc (commit)
      from  5cb7e7f17c1fc2bf86ab3ae218a32f60755a09f6 (commit)

Summary of changes:
 lib/RT/Handle.pm                   |   14 ++++++++++++--
 share/html/Install/Initialize.html |    2 +-
 2 files changed, 13 insertions(+), 3 deletions(-)

- Log -----------------------------------------------------------------
commit 80e6a7c4210c5339fdbb0c0d5e76cbc20f9416bc
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Jan 18 12:15:32 2012 -0500

    Don't disconnect from the database after RT::Handle->InsertData in the web installer
    
    Disconnecting and then immediately redirecting gets the next request an
    uninitialized database handle.  This caused query execution errors in
    /Elements/Header which produced warnings under Pg.
    
    Rather than reconnecting afterwards, just add an option to InsertData to
    skip the disconnect in the first place.
    
    Our new t/web/installer.t test file now passes on SQLite, Pg, mysql.

diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 308f5ba..b34f67a 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -748,6 +748,10 @@ sub InsertData {
     my $self     = shift;
     my $datafile = shift;
     my $root_password = shift;
+    my %args     = (
+        disconnect_after => 1,
+        @_
+    );
 
     # Slurp in stuff to insert from the datafile. Possible things to go in here:-
     our (@Groups, @Users, @ACL, @Queues, @ScripActions, @ScripConditions,
@@ -1071,8 +1075,14 @@ sub InsertData {
         $RT::Logger->debug("done.");
     }
 
-    my $db_type = RT->Config->Get('DatabaseType');
-    $RT::Handle->Disconnect() unless $db_type eq 'SQLite';
+    # XXX: This disconnect doesn't really belong here; it's a relict from when
+    # this method was extracted from rt-setup-database.  However, too much
+    # depends on it to change without significant testing.  At the very least,
+    # we can provide a way to skip the side-effect.
+    if ( $args{disconnect_after} ) {
+        my $db_type = RT->Config->Get('DatabaseType');
+        $RT::Handle->Disconnect() unless $db_type eq 'SQLite';
+    }
 
     $RT::Logger->debug("Done setting up database content.");
 
diff --git a/share/html/Install/Initialize.html b/share/html/Install/Initialize.html
index afef3fa..d763314 100644
--- a/share/html/Install/Initialize.html
+++ b/share/html/Install/Initialize.html
@@ -125,7 +125,7 @@ if ( $Run ) {
                 $RT::Handle = RT::Handle->new;
                 RT::Init();
                 my $file = $RT::EtcPath . "/initialdata";
-                ($status, $msg) = $RT::Handle->InsertData( $file );
+                ($status, $msg) = $RT::Handle->InsertData( $file, undef, disconnect_after => 0 );
             }
             unless ( $status ) {
                 push @errors, loc('ERROR: [_1]', $msg);

-----------------------------------------------------------------------


More information about the Rt-commit mailing list