[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[6577] branches/1.3



Revision: 6577
          http://sourceforge.net/p/ledger-smb/code/6577
Author:   ehuelsmann
Date:     2014-01-21 09:15:39 +0000 (Tue, 21 Jan 2014)
Log Message:
-----------
Fix bug #953 (encoding issue with accented characters.

Modified Paths:
--------------
    branches/1.3/LedgerSMB/DBObject/User.pm
    branches/1.3/LedgerSMB/Form.pm
    branches/1.3/LedgerSMB/User.pm
    branches/1.3/LedgerSMB.pm
    branches/1.3/scripts/setup.pl

Modified: branches/1.3/LedgerSMB/DBObject/User.pm
===================================================================
--- branches/1.3/LedgerSMB/DBObject/User.pm	2014-01-21 09:14:52 UTC (rev 6576)
+++ branches/1.3/LedgerSMB/DBObject/User.pm	2014-01-21 09:15:39 UTC (rev 6577)
@@ -68,7 +68,8 @@
     # Just in case, however, I think it is a good idea to include the DBI
     # error string.  CT
     $self->{dbh} = DBI->connect(
-        qq|dbi:Pg:dbname="$dbname"|, "$self->{login}", "$self->{old_password}", { AutoCommit => 0 }
+        qq|dbi:Pg:dbname="$dbname"|, "$self->{login}", "$self->{old_password}",
+        { AutoCommit => 0, pg_enable_utf8 => 1 }
     ); 
     if (!$self->{dbh}){
         $self->error($self->{_locale}->text('Incorrect Password'));

Modified: branches/1.3/LedgerSMB/Form.pm
===================================================================
--- branches/1.3/LedgerSMB/Form.pm	2014-01-21 09:14:52 UTC (rev 6576)
+++ branches/1.3/LedgerSMB/Form.pm	2014-01-21 09:15:39 UTC (rev 6577)
@@ -1373,10 +1373,10 @@
     }
     my $dbname = $self->{company};
     $self->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$dbname"|, $login, $password,
-           { AutoCommit => 0 }) || LedgerSMB::Auth::credential_prompt();
+           { AutoCommit => 0, pg_enable_utf8 => 1, pg_server_prepare => 0 })
+        || LedgerSMB::Auth::credential_prompt();
 
     $logger->debug("acquired dbh \$self->{dbh}=$self->{dbh}");
-    $self->{dbh}->{pg_server_prepare} = 0;
     my $dbh = $self->{dbh};
 
     my $datequery = 'select dateformat from user_preference join users using(id)
@@ -1567,9 +1567,9 @@
 
     # connect to database
     my $dbh = DBI->connect( $myconfig->{dbconnect},
-        $myconfig->{dbuser}, $myconfig->{dbpasswd} )
+        $myconfig->{dbuser}, $myconfig->{dbpasswd},
+        { AutoCommit => 0, pg_server_prepare => 0, pg_enable_utf8 => 1 })
       or $self->dberror;
-    $dbh->{pg_enable_utf8} = 1;
 
     # set db options
     if ( $myconfig->{dboptions} ) {
@@ -1593,7 +1593,7 @@
     # connect to database
     my $dbh = DBI->connect(
         $myconfig->{dbconnect}, $myconfig->{dbuser},
-        $myconfig->{dbpasswd}, { AutoCommit => 0 }
+        $myconfig->{dbpasswd}, { AutoCommit => 0, pg_enable_utf8 => 1 }
     ) or $self->dberror;
     #HV trying to trace DBI->connect statements
     $logger->debug("DBI->connect dbh=$dbh");
@@ -1604,8 +1604,6 @@
      $dbh->trace(split /=/,$dbi_trace,2);#http://search.cpan.org/~timb/DBI-1.616/DBI.pm#TRACING
     }
 
-    $dbh->{pg_enable_utf8} = 1;
-
     # set db options
     if ( $myconfig->{dboptions} ) {
         $dbh->do( $myconfig->{dboptions} );

Modified: branches/1.3/LedgerSMB/User.pm
===================================================================
--- branches/1.3/LedgerSMB/User.pm	2014-01-21 09:14:52 UTC (rev 6576)
+++ branches/1.3/LedgerSMB/User.pm	2014-01-21 09:15:39 UTC (rev 6577)
@@ -288,9 +288,9 @@
     &dbconnect_vars( $form, $form->{dbdefault} );
 
     my $dbh =
-      DBI->connect( $form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd} )
+      DBI->connect( $form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd},
+                    { pg_enable_utf8 => 1 })
       or $form->dberror( __FILE__ . ':' . __LINE__ );
-    $dbh->{pg_enable_utf8} = 1;
 
     if ( $form->{dbdriver} eq 'Pg' ) {
 
@@ -307,9 +307,8 @@
                 &dbconnect_vars( $form, $db );
                 my $dbh =
                   DBI->connect( $form->{dbconnect}, $form->{dbuser},
-                    $form->{dbpasswd} )
+                    $form->{dbpasswd}, { pg_enable_utf8 => 1} )
                   or $form->dberror( __FILE__ . ':' . __LINE__ );
-                $dbh->{pg_enable_utf8} = 1;
 
                 $query = qq|
                     SELECT tablename FROM pg_tables
@@ -359,9 +358,8 @@
     if ( $form->{dbsuperuser} ) {
         my $superdbh =
           DBI->connect( $form->{dbconnect}, $form->{dbsuperuser},
-            $form->{dbsuperpasswd} )
+            $form->{dbsuperpasswd}, { pg_enable_utf8 => 1 } )
           or $form->dberror( __FILE__ . ':' . __LINE__ );
-        $superdbh->{pg_enable_utf8} = 1;
         my $query = qq|$dbcreate{$form->{dbdriver}}|;
         $superdbh->do($query)
           || $form->dberror( __FILE__ . ':' . __LINE__ . $query );
@@ -374,15 +372,14 @@
     &dbconnect_vars( $form, $form->{db} );
 
     my $dbh =
-      DBI->connect( $form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd} )
+      DBI->connect( $form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd},
+                    { pg_enable_utf8 => 1 })
       or $form->dberror( __FILE__ . ':' . __LINE__ );
-    $dbh->{pg_enable_utf8} = 1;
     if ( $form->{dbsuperuser} ) {
         my $superdbh =
           DBI->connect( $form->{dbconnect}, $form->{dbsuperuser},
-            $form->{dbsuperpasswd} )
+            $form->{dbsuperpasswd}, { pg_enable_utf8 => 1 } )
           or $form->dberror( __FILE__ . ':' . __LINE__ );
-        $superdbh->{pg_enable_utf8} = 1;
 
         # JD: We need to check for plpgsql,
         # if it isn't there create it, if we can't error
@@ -465,9 +462,9 @@
     $form->{sid} = $form->{dbdefault};
     &dbconnect_vars( $form, $form->{dbdefault} );
     my $dbh =
-      DBI->connect( $form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd} )
+      DBI->connect( $form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd},
+                    { pg_enable_utf8 => 1 } )
       or $form->dberror( __FILE__ . ':' . __LINE__ );
-    $dbh->{pg_enable_utf8} = 1;
     my $query = qq|DROP DATABASE "$form->{db}"|;
     $dbh->do($query) || $form->dberror( __FILE__ . ':' . __LINE__ . $query );
 
@@ -536,9 +533,9 @@
     &dbconnect_vars( $form, $form->{dbdefault} );
 
     my $dbh =
-      DBI->connect( $form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd} )
+      DBI->connect( $form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd},
+                    { pg_enable_utf8 => 1 })
       or $form->dberror( __FILE__ . ':' . __LINE__ );
-    $dbh->{pg_enable_utf8} = 1;
 
     if ( $form->{dbdriver} =~ /Pg/ ) {
 
@@ -559,9 +556,8 @@
 
             my $dbh =
               DBI->connect( $form->{dbconnect}, $form->{dbuser},
-                $form->{dbpasswd} )
+                $form->{dbpasswd}, { pg_enable_utf8 => 1 } )
               or $form->dberror( __FILE__ . ':' . __LINE__ );
-            $dbh->{pg_enable_utf8} = 1;
 
             $query = qq|
                 SELECT tablename 
@@ -631,9 +627,8 @@
 
         my $dbh = DBI->connect(
             $form->{dbconnect}, $form->{dbuser},
-            $form->{dbpasswd}, { AutoCommit => 0 }
+            $form->{dbpasswd}, { AutoCommit => 0, pg_enable_utf8 => 1 }
         ) or $form->dberror( __FILE__ . ':' . __LINE__ );
-        $dbh->{pg_enable_utf8} = 1;
 
         # check version
         $query = qq|
@@ -891,9 +886,8 @@
         # check if login is in database
         my $dbh = DBI->connect(
             $self->{dbconnect}, $self->{dbuser},
-            $self->{dbpasswd}, { AutoCommit => 0 }
+            $self->{dbpasswd}, { AutoCommit => 0, pg_enable_utf8 => 1 }
         ) or $self->error($DBI::errstr);
-        $dbh->{pg_enable_utf8} = 1;
 
         # add login to employees table if it does not exist
         my $login = $self->{login};
@@ -951,9 +945,8 @@
 
     my $dbh = DBI->connect(
         $form->{dbconnect}, $form->{dbuser},
-        $form->{dbpasswd}, { AutoCommit => 0 }
+        $form->{dbpasswd}, { AutoCommit => 0, pg_enable_utf8 => 1 }
     ) or $form->dberror( __FILE__ . ':' . __LINE__ );
-    $dbh->{pg_enable_utf8} = 1;
 
     my $login = $form->{login};
     $login =~ s/@.*//;

Modified: branches/1.3/LedgerSMB.pm
===================================================================
--- branches/1.3/LedgerSMB.pm	2014-01-21 09:14:52 UTC (rev 6576)
+++ branches/1.3/LedgerSMB.pm	2014-01-21 09:15:39 UTC (rev 6577)
@@ -986,7 +986,8 @@
     # Just in case, however, I think it is a good idea to include the DBI
     # error string.  CT
     $self->{dbh} = DBI->connect(
-        qq|dbi:Pg:dbname="$dbname"|, "$creds->{login}", "$creds->{password}", { AutoCommit => 0 }
+        qq|dbi:Pg:dbname="$dbname"|, "$creds->{login}", "$creds->{password}",
+        { AutoCommit => 0, pg_server_prepare => 0, pg_enable_utf8 => 1 }
     ); 
     $logger->debug("DBI->connect dbh=$self->{dbh}");
     my $dbi_trace=$LedgerSMB::Sysconfig::DBI_TRACE;
@@ -1007,8 +1008,6 @@
     elsif (!$self->{dbh}){
         $self->_get_password;
     }
-    $self->{dbh}->{pg_server_prepare} = 0;
-    $self->{dbh}->{pg_enable_utf8} = 1;
     $LedgerSMB::App_State::DBH = $self->{dbh};
     $LedgerSMB::App_State::DBName = $dbname;
 

Modified: branches/1.3/scripts/setup.pl
===================================================================
--- branches/1.3/scripts/setup.pl	2014-01-21 09:14:52 UTC (rev 6576)
+++ branches/1.3/scripts/setup.pl	2014-01-21 09:15:39 UTC (rev 6577)
@@ -344,7 +344,8 @@
     $ENV{PGDATABASE} = $request->{database};
 
     # Credentials set above via environment variables --CT
-    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|);
+    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|,
+        undef, undef, { pg_enable_utf8 => 1 });
     my $locale = $request->{_locale};
 
     my @pre_upgrade_checks = (
@@ -475,7 +476,8 @@
     $ENV{PGDATABASE} = $request->{database};
 
     # Credentials set above via environment variables --CT
-    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|);
+    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|,
+        undef, undef, { pg_enable_utf8 => 1 });
     my $dbh = $request->{dbh};
     $dbh->do('ALTER SCHEMA public RENAME TO sl28');
     $dbh->do('CREATE SCHEMA PUBLIC');
@@ -509,7 +511,8 @@
     $rc2 = system("psql -f $temp/sl2.8-1.3-upgrade.sql >> $temp/dblog_stdout 2>>$temp/dblog_stderr");
     $rc ||= $rc2;
 
-    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|);
+    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|,
+                                   undef, undef, { pg_enable_utf8 => 1 });
 
    @{$request->{salutations}} 
     = $request->call_procedure(procname => 'person__list_salutations' ); 
@@ -581,7 +584,8 @@
     $ENV{PGDATABASE} = $request->{database};
 
     # Credentials set above via environment variables --CT
-    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|);
+    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|,
+                                   undef, undef, { pg_enable_utf8 => 1 });
     my $locale = $request->{_locale};
 
     my @pre_upgrade_checks = (
@@ -734,7 +738,8 @@
     $ENV{PGDATABASE} = $request->{database};
 
     # Credentials set above via environment variables --CT
-    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|);
+    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|,
+                                   undef, undef, { pg_enable_utf8 => 1 });
     my $locale = $request->{_locale};
 
     my $table = $request->{dbh}->quote_identifier($request->{table});
@@ -949,7 +954,8 @@
 
 
 
-    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|);
+    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|,
+                                   undef, undef, { pg_enable_utf8 => 1 });
     $request->{dbh}->{AutoCommit} = 0;
 
     @{$request->{salutations}} 
@@ -993,7 +999,8 @@
     my $creds = LedgerSMB::Auth::get_credentials();
     $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|,
                                    $creds->{login},
-                                   $creds->{password});
+                                   $creds->{password},
+                                   { pg_enable_utf8 => 1 });
     $LedgerSMB::App_State::DBH = $request->{dbh};
     my $user = LedgerSMB::DBObject::Admin->new({base => $request});
     if (8 == $user->save_user){ # Told not to import but user exists in db
@@ -1068,7 +1075,8 @@
     $ENV{PGDATABASE} = $request->{database};
 
     # Credentials set above via environment variables --CT
-    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|);
+    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|,
+                                   undef, undef, { pg_enable_utf8 => 1 });
     my $dbh = $request->{dbh};
     $dbh->do('ALTER SCHEMA public RENAME TO lsmb12');
     $dbh->do('CREATE SCHEMA PUBLIC');
@@ -1100,7 +1108,8 @@
     $rc2 = system("psql -f $temp/1.2-1.3-upgrade.sql >> $temp/dblog_stdout 2>>$temp/dblog_stderr");
     $rc ||= $rc2;
 
-    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|);
+    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|,
+                                   undef, undef, { pg_enable_utf8 => 1 });
 
    @{$request->{salutations}} 
     = $request->call_procedure(procname => 'person__list_salutations' ); 
@@ -1158,7 +1167,9 @@
     $request->{lsmb_info} = $database->lsmb_info();
     # Credentials set above via environment variables --CT
     #avoid msg commit ineffective with AutoCommit enabled
-    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|,$creds->{login},$creds->{password},{AutoCommit=>0});
+    $request->{dbh} = DBI->connect(qq|dbi:Pg:dbname="$request->{database}"|,
+                                   $creds->{login},$creds->{password},
+                                   { AutoCommit => 0, pg_enable_utf8 => 1 });
     my $dbh = $request->{dbh};
     my $sth = $dbh->prepare(
           'UPDATE defaults SET value = ? WHERE setting_key = ?'

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits