[Rt-commit] rt branch, 4.0-trunk, updated. rt-3.9.7-1187-g7ed81c0

Ruslan Zakirov ruz at bestpractical.com
Tue Jan 11 02:35:26 EST 2011


The branch, 4.0-trunk has been updated
       via  7ed81c02d5c3217ece819c7a632c73329763dae0 (commit)
      from  4bdef722df1968148737eb78230c9dcfe0b8b702 (commit)

Summary of changes:
 lib/RT/Handle.pm |   25 ++++++++++---------------
 1 files changed, 10 insertions(+), 15 deletions(-)

- Log -----------------------------------------------------------------
commit 7ed81c02d5c3217ece819c7a632c73329763dae0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jan 11 10:33:30 2011 +0300

    we shouldn't use DBI->connect directly
    
    some smart DBD drivers (for example Oracle) cache environment
    on first connect and then re-use it :(

diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index b3847be..49b5140 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -222,36 +222,31 @@ sub SystemDSN {
 
 sub CheckIntegrity {
     my $self = shift;
-    
-    my $dsn = $self->DSN;
-    my $user = RT->Config->Get('DatabaseUser');
-    my $pass = RT->Config->Get('DatabasePassword');
+    $self = new $self unless ref $self;
 
-    my $dbh = DBI->connect(
-        $dsn, $user, $pass,
-        { RaiseError => 0, PrintError => 0 },
-    );
-    unless ( $dbh ) {
-        return (0, 'no connection', "Failed to connect to $dsn as user '$user': ". $DBI::errstr);
-    }
+    do {
+        local $@;
+        unless ( eval { RT::ConnectToDatabase(); 1 } ) {
+            return (0, 'no connection', "$@");
+        }
+    };
 
-    RT::ConnectToDatabase();
     RT::InitLogging();
 
     require RT::CurrentUser;
     my $test_user = RT::CurrentUser->new;
     $test_user->Load('RT_System');
     unless ( $test_user->id ) {
-        return (0, 'no system user', "Couldn't find RT_System user in the DB '$dsn'");
+        return (0, 'no system user', "Couldn't find RT_System user in the DB '". $self->DSN ."'");
     }
 
     $test_user = RT::CurrentUser->new;
     $test_user->Load('Nobody');
     unless ( $test_user->id ) {
-        return (0, 'no nobody user', "Couldn't find Nobody user in the DB '$dsn'");
+        return (0, 'no nobody user', "Couldn't find Nobody user in the DB '". $self->DSN ."'");
     }
 
-    return $dbh;
+    return $RT::Handle->dbh;
 }
 
 sub CheckCompatibility {

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


More information about the Rt-commit mailing list