X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDBUpgrade2.pm;h=5c8280b2c067555f47cb2e97f52a45e97dc5b783;hb=2b8804456d1d3ee249a70d98679ea3a934b25a39;hp=eb366e1222a8fa010530876c780cdec7b450bef8;hpb=e9c922aa60e3b5107de51862f72cef2f2a66f17a;p=kivitendo-erp.git diff --git a/SL/DBUpgrade2.pm b/SL/DBUpgrade2.pm index eb366e122..5c8280b2c 100644 --- a/SL/DBUpgrade2.pm +++ b/SL/DBUpgrade2.pm @@ -147,9 +147,6 @@ sub process_query { # Remove DOS and Unix style line endings. chomp; - # remove comments - s/--.*$//; - for (my $i = 0; $i < length($_); $i++) { my $char = substr($_, $i, 1); @@ -176,6 +173,11 @@ sub process_query { && $tag =~ /^ (?= [A-Za-z_] [A-Za-z0-9_]* | ) $/x) { # tag is identifier push @quote_chars, $char = '$' . $tag . '$'; $i = $tag_end; + } elsif ($char eq "-") { + if ( substr($_, $i+1, 1) eq "-") { + # found a comment outside quote + last; + } } elsif ($char eq ";") { # Query is complete. Send it. @@ -186,11 +188,13 @@ sub process_query { return $errstr // '' 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:
${query}
" . - "The error message was: ${errstr}
" . - "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:
${query}
" . + "The error message was: ${errstr}
" . + "All changes in that file have been reverted.") + } } $sth->finish(); @@ -239,7 +243,6 @@ sub process_perl_script { $dbh->begin_work; # setup dbup_ export vars & run script - my $old_dbh = $::form->set_standard_dbh($dbh); my %dbup_myconfig = map { ($_ => $::form->{$_}) } qw(dbname dbuser dbpasswd dbhost dbport dbconnect); my $result = eval { SL::DBUpgrade2::Base::execute_script( @@ -252,18 +255,16 @@ sub process_perl_script { my $error = $EVAL_ERROR; - $::form->set_standard_dbh($old_dbh); - $dbh->rollback if 1 != ($result // -1); return $error if $self->{return_on_error} && (1 != ($result // -1)); if (!defined($result)) { print $::form->parse_html_template("dbupgrade/error", { file => $filename, error => $error }); - ::end_of_request(); + $::dispatcher->end_request; } elsif (1 != $result) { SL::System::InstallationLock->unlock if 2 == $result; - ::end_of_request(); + $::dispatcher->end_request; } if (ref($version_or_control) eq "HASH") {