Bug 8597 follow-up translation issues
[koha.git] / C4 / Installer.pm
index 1c177b9..c1f356f 100644 (file)
@@ -20,9 +20,9 @@ package C4::Installer;
 use strict;
 #use warnings; FIXME - Bug 2505
 
-our $VERSION = 3.00;
+our $VERSION = 3.07.00.049;
 use C4::Context;
-use C4::Installer::PerlModules 1.000000;
+use C4::Installer::PerlModules;
 
 =head1 NAME
 
@@ -508,8 +508,13 @@ sub load_sql {
     my $datadir = C4::Context->config('intranetdir') . "/installer/data/$self->{dbms}";
     my $error;
     my $strcmd;
+    my $cmd;
     if ( $self->{dbms} eq 'mysql' ) {
-        $strcmd = "mysql "
+        $cmd = qx(which mysql 2>/dev/null || whereis mysql 2>/dev/null);
+        chomp $cmd;
+        $cmd = $1 if ($cmd && $cmd =~ /^(.+?)[\r\n]+$/);
+        $cmd = 'mysql' if (!$cmd || !-x $cmd);
+        $strcmd = "$cmd "
             . ( $self->{hostname} ? " -h $self->{hostname} " : "" )
             . ( $self->{port}     ? " -P $self->{port} "     : "" )
             . ( $self->{user}     ? " -u $self->{user} "     : "" )
@@ -517,7 +522,11 @@ sub load_sql {
             . " $self->{dbname} ";
         $error = qx($strcmd --default-character-set=utf8 <$filename 2>&1 1>/dev/null);
     } elsif ( $self->{dbms} eq 'Pg' ) {
-        $strcmd = "psql "
+        $cmd = qx(which psql 2>/dev/null || whereis psql 2>/dev/null);
+        chomp $cmd;
+        $cmd = $1 if ($cmd && $cmd =~ /^(.+?)[\r\n]+$/);
+        $cmd = 'psql' if (!$cmd || !-x $cmd);
+        $strcmd = "$cmd "
             . ( $self->{hostname} ? " -h $self->{hostname} " : "" )
             . ( $self->{port}     ? " -p $self->{port} "     : "" )
             . ( $self->{user}     ? " -U $self->{user} "     : "" )
@@ -529,8 +538,10 @@ sub load_sql {
         # report the import a failure although it really succeded -fbcit
     }
 #   errors thrown while loading installer data should be logged
-    warn "C4::Installer::load_sql returned the following errors while attempting to load $filename:\n";
-    warn $error;
+    if($error) {
+      warn "C4::Installer::load_sql returned the following errors while attempting to load $filename:\n";
+      warn "$error";
+    }
     return $error;
 }