]> wagnertech.de Git - kivitendo-erp.git/blobdiff - SL/DBUpgrade2.pm
trim-Funktion zum Entfernen führender und anhängender Whitespaces
[kivitendo-erp.git] / SL / DBUpgrade2.pm
index 6d0b207a7812342798c6fd5d907631af9a75bd3f..840a1dd7cecdc9801f6810c8dc6e2fc0bcab0156 100644 (file)
@@ -26,7 +26,7 @@ sub init {
 
   $params{path_suffix} ||= '';
   $params{schema}      ||= '';
 
   $params{path_suffix} ||= '';
   $params{schema}      ||= '';
-  $params{path}          = "sql/Pg-upgrade2" . $params{path_suffix};
+  $params{path}        ||= "sql/Pg-upgrade2" . $params{path_suffix};
 
   map { $self->{$_} = $params{$_} } keys %params;
 
 
   map { $self->{$_} = $params{$_} } keys %params;
 
@@ -38,8 +38,6 @@ sub path {
 }
 
 sub parse_dbupdate_controls {
 }
 
 sub parse_dbupdate_controls {
-  $::lxdebug->enter_sub();
-
   my ($self) = @_;
 
   my $form   = $self->{form};
   my ($self) = @_;
 
   my $form   = $self->{form};
@@ -59,6 +57,7 @@ sub parse_dbupdate_controls {
     my $control = {
       "priority" => 1000,
       "depends"  => [],
     my $control = {
       "priority" => 1000,
       "depends"  => [],
+      "locales"  => [],
     };
 
     while (<IN>) {
     };
 
     while (<IN>) {
@@ -73,6 +72,8 @@ sub parse_dbupdate_controls {
 
       if ($fields[0] eq "depends") {
         push(@{$control->{"depends"}}, split(/\s+/, $fields[1]));
 
       if ($fields[0] eq "depends") {
         push(@{$control->{"depends"}}, split(/\s+/, $fields[1]));
+      } elsif ($fields[0] eq "locales") {
+        push @{$control->{locales}}, $fields[1];
       } else {
         $control->{$fields[0]} = $fields[1];
       }
       } else {
         $control->{$fields[0]} = $fields[1];
       }
@@ -121,8 +122,6 @@ sub parse_dbupdate_controls {
 
   $self->{all_controls} = \%all_controls;
 
 
   $self->{all_controls} = \%all_controls;
 
-  $::lxdebug->leave_sub();
-
   return $self;
 }
 
   return $self;
 }
 
@@ -187,11 +186,13 @@ sub process_query {
             return $errstr // '<unknown database error>' if $self->{return_on_error};
             $sth->finish();
             $dbh->rollback();
             return $errstr // '<unknown database error>' if $self->{return_on_error};
             $sth->finish();
             $dbh->rollback();
-            $form->dberror("The database update/creation did not succeed. " .
-                           "The file ${filename} containing the following " .
-                           "query failed:<br>${query}<br>" .
-                           "The error message was: ${errstr}<br>" .
-                           "All changes in that file have been reverted.");
+            if (!ref $version_or_control || ref $version_or_control ne 'HASH' || !$version_or_control->{may_fail})  {
+              $form->dberror("The database update/creation did not succeed. " .
+                             "The file ${filename} containing the following " .
+                             "query failed:<br>${query}<br>" .
+                             "The error message was: ${errstr}<br>" .
+                             "All changes in that file have been reverted.")
+            }
           }
           $sth->finish();
 
           }
           $sth->finish();
 
@@ -235,7 +236,7 @@ sub process_perl_script {
 
   my ($self, $dbh, $filename, $version_or_control) = @_;
 
 
   my ($self, $dbh, $filename, $version_or_control) = @_;
 
-  my %form_values = map { $_ => $::form->{$_} } qw(dbconnect dbdefault dbhost dbname dboptions dbpasswd dbport dbupdate dbuser login template_object version);
+  my %form_values = %$::form;
 
   $dbh->begin_work;
 
 
   $dbh->begin_work;
 
@@ -378,13 +379,11 @@ sub _control_error {
 }
 
 sub _dbupdate2_calculate_depth {
 }
 
 sub _dbupdate2_calculate_depth {
-  $::lxdebug->enter_sub(2);
-
   my ($tree, $tag) = @_;
 
   my $node = $tree->{$tag};
 
   my ($tree, $tag) = @_;
 
   my $node = $tree->{$tag};
 
-  return $::lxdebug->leave_sub(2) if (defined($node->{"depth"}));
+  return if (defined($node->{"depth"}));
 
   my $max_depth = 0;
 
 
   my $max_depth = 0;
 
@@ -395,8 +394,6 @@ sub _dbupdate2_calculate_depth {
   }
 
   $node->{"depth"} = $max_depth + 1;
   }
 
   $node->{"depth"} = $max_depth + 1;
-
-  $::lxdebug->leave_sub(2);
 }
 
 sub sort_dbupdate_controls {
 }
 
 sub sort_dbupdate_controls {