From: Moritz Bunkus Date: Mon, 29 Nov 2010 16:49:06 +0000 (+0100) Subject: DRY X-Git-Tag: release-2.6.2beta1~17^2~11^2~9 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=35636cc25a82dee3dda2f16891b5e2ef07f72834;p=kivitendo-erp.git DRY --- diff --git a/SL/DBUpgrade2.pm b/SL/DBUpgrade2.pm index 7725bd6bc..d52468eee 100644 --- a/SL/DBUpgrade2.pm +++ b/SL/DBUpgrade2.pm @@ -276,6 +276,16 @@ sub process_perl_script { $main::lxdebug->leave_sub(); } +sub process_file { + my ($self, $dbh, $filename, $version_or_control, $db_charset) = @_; + + if ($filename =~ m/sql$/) { + $self->process_query($dbh, $filename, $version_or_control, $db_charset); + } else { + $self->process_perl_script($dbh, $filename, $version_or_control, $db_charset); + } +} + sub _check_for_loops { my ($form, $file_name, $controls, $tag, @path) = @_; diff --git a/SL/User.pm b/SL/User.pm index 838b6a696..a30d54136 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -624,7 +624,6 @@ sub dbupdate { foreach my $upgradescript (@upgradescripts) { my $a = $upgradescript; $a =~ s/^\Q$form->{dbdriver}\E-upgrade-|\.(sql|pl)$//g; - my $file_type = $1; my ($mindb, $maxdb) = split /-/, $a; my $str_maxdb = $maxdb; @@ -638,11 +637,7 @@ sub dbupdate { # apply upgrade $main::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $upgradescript"); - if ($file_type eq "sql") { - $dbupdater->process_query($dbh, "sql/" . $form->{"dbdriver"} . "-upgrade/$upgradescript", $str_maxdb, $db_charset); - } else { - $dbupdater->process_perl_script($dbh, "sql/" . $form->{"dbdriver"} . "-upgrade/$upgradescript", $str_maxdb, $db_charset); - } + $dbupdater->process_file($dbh, "sql/" . $form->{"dbdriver"} . "-upgrade/$upgradescript", $str_maxdb, $db_charset); $version = $maxdb; @@ -722,11 +717,7 @@ sub dbupdate2 { $main::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $control->{file}"); print $form->parse_html_template("dbupgrade/upgrade_message2", $control); - if ($file_type eq "sql") { - $dbupdater->process_query($dbh, "sql/" . $form->{"dbdriver"} . "-upgrade2/$control->{file}", $control, $db_charset); - } else { - $dbupdater->process_perl_script($dbh, "sql/" . $form->{"dbdriver"} . "-upgrade2/$control->{file}", $control, $db_charset); - } + $dbupdater->process_file($dbh, "sql/" . $form->{"dbdriver"} . "-upgrade2/$control->{file}", $control, $db_charset); } $rc = 0;