X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/dfefe1cf599541143e94e1356d6be0edc53e8059..dbda14c263efd93aca3b7114015a47d86b8581e3:/SL/DBUpgrade2.pm diff --git a/SL/DBUpgrade2.pm b/SL/DBUpgrade2.pm index cdfca9b74..54a651c05 100644 --- a/SL/DBUpgrade2.pm +++ b/SL/DBUpgrade2.pm @@ -82,7 +82,7 @@ sub parse_dbupdate_controls { next if ($control->{ignore}); $control->{charset} = 'UTF-8' if $file =~ m/\.pl$/; - $control->{charset} = $control->{charset} || $control->{encoding} || Common::DEFAULT_CHARSET; + $control->{charset} = $control->{charset} || $control->{encoding} || 'UTF-8'; if (!$control->{"tag"}) { _control_error($form, $file_name, $locale->text("Missing 'tag' field.")) ; @@ -133,7 +133,7 @@ sub parse_dbupdate_controls { sub process_query { $::lxdebug->enter_sub(); - my ($self, $dbh, $filename, $version_or_control, $db_charset) = @_; + my ($self, $dbh, $filename, $version_or_control) = @_; my $form = $self->{form}; my $fh = IO::File->new($filename, "r") or $form->error("$filename : $!\n"); @@ -141,7 +141,7 @@ sub process_query { my $sth; my @quote_chars; - my $file_charset = Common::DEFAULT_CHARSET; + my $file_charset = 'UTF-8'; while (<$fh>) { last if !/^--/; next if !/^--\s*\@(?:charset|encoding):\s*(.+)/; @@ -150,12 +150,10 @@ sub process_query { } $fh->seek(0, SEEK_SET); - $db_charset ||= Common::DEFAULT_CHARSET; - $dbh->begin_work(); while (<$fh>) { - $_ = SL::Iconv::convert($file_charset, $db_charset, $_); + $_ = SL::Iconv::convert($file_charset, 'UTF-8', $_); # Remove DOS and Unix style line endings. chomp; @@ -241,7 +239,7 @@ sub process_query { sub process_perl_script { $::lxdebug->enter_sub(); - my ($self, $dbh, $filename, $version_or_control, $db_charset) = @_; + my ($self, $dbh, $filename, $version_or_control) = @_; my %form_values = map { $_ => $::form->{$_} } qw(dbconnect dbdefault dbhost dbmbkiviunstable dbname dboptions dbpasswd dbport dbupdate dbuser login template_object version); @@ -288,12 +286,12 @@ sub process_perl_script { } sub process_file { - my ($self, $dbh, $filename, $version_or_control, $db_charset) = @_; + my ($self, $dbh, $filename, $version_or_control) = @_; if ($filename =~ m/sql$/) { - $self->process_query($dbh, $filename, $version_or_control, $db_charset); + $self->process_query($dbh, $filename, $version_or_control); } else { - $self->process_perl_script($dbh, $filename, $version_or_control, $db_charset); + $self->process_perl_script($dbh, $filename, $version_or_control); } } @@ -357,10 +355,9 @@ sub apply_admin_dbupgrade_scripts { return 0 if !@unapplied_scripts; - my $db_charset = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET; $self->{form}->{login} ||= 'admin'; - map { $_->{description} = SL::Iconv::convert($_->{charset}, $db_charset, $_->{description}) } values %{ $self->{all_controls} }; + map { $_->{description} = SL::Iconv::convert($_->{charset}, 'UTF-8', $_->{description}) } values %{ $self->{all_controls} }; if ($called_from_admin) { $self->{form}->{title} = $::locale->text('Dataset upgrade'); @@ -373,7 +370,7 @@ sub apply_admin_dbupgrade_scripts { $::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $control->{file}"); print $self->{form}->parse_html_template("dbupgrade/upgrade_message2", $control); - $self->process_file($dbh, "sql/Pg-upgrade2-auth/$control->{file}", $control, $db_charset); + $self->process_file($dbh, "sql/Pg-upgrade2-auth/$control->{file}", $control); } print $self->{form}->parse_html_template("dbupgrade/footer", { is_admin => 1 }) if $called_from_admin; @@ -617,25 +614,22 @@ are missing/wrong (e.g. a tag name listed in C is not found). Sets C<$Self->{all_controls}> to the list of database scripts. -=item C +=item C Applies a single database upgrade file. Calls L for Perl update files and C for SQL update files. Requires an open database handle(C<$dbh>), the file name -(C<$filename>), a hash structure of the file's control fields as -produced by L (C<$version_or_control>) and -the database charset (for on-the-fly charset recoding of the script if -required, C<$db_charset>). +(C<$filename>) and a hash structure of the file's control fields as +produced by L (C<$version_or_control>). Returns the result of the actual function called. -=item C +=item C Applies a single Perl database upgrade file. Requires an open database -handle(C<$dbh>), the file name (C<$filename>), a hash structure of the -file's control fields as produced by L -(C<$version_or_control>) and the database charset (for on-the-fly -charset recoding of the script if required, C<$db_charset>). +handle(C<$dbh>), the file name (C<$filename>) and a hash structure of +the file's control fields as produced by L +(C<$version_or_control>). Perl scripts are executed via L. If L returns falsish then an error is expected. There are two special return values: If the @@ -675,13 +669,12 @@ the following function: } } -=item C +=item C Applies a single SQL database upgrade file. Requires an open database -handle(C<$dbh>), the file name (C<$filename>), a hash structure of the -ofile's control fields as produced by L -(C<$version_or_control>) and the database charset (for on-the-fly -charset recoding of the script if required, C<$db_charset>). +handle(C<$dbh>), the file name (C<$filename>), and a hash structure of +the file's control fields as produced by L +(C<$version_or_control>). =item C