Bug 32336: (QA follow-up) Use $metadata->schema
[srvgit] / installer / install.pl
index 3d410f3..f8de23e 100755 (executable)
@@ -54,7 +54,7 @@ if ( defined($language) ) {
 
 my $installer = C4::Installer->new();
 my %info;
-$info{'dbname'} = C4::Context->config("database");
+$info{'dbname'} = C4::Context->config("database_test") || C4::Context->config("database");
 $info{'dbms'}   = (
       C4::Context->config("db_scheme")
     ? C4::Context->config("db_scheme")
@@ -327,7 +327,8 @@ elsif ( $step && $step == 3 ) {
         my $dir =
           C4::Context->config('intranetdir')
           . "/installer/data/$info{dbms}/$langchoice/marcflavour";
-        unless ( opendir( MYDIR, $dir ) ) {
+        my $dir_h;
+        unless ( opendir( $dir_h, $dir ) ) {
             if ( $langchoice eq 'en' ) {
                 warn "cannot open MARC frameworks directory $dir";
             }
@@ -336,12 +337,12 @@ elsif ( $step && $step == 3 ) {
                 # default to English
                 $dir = C4::Context->config('intranetdir')
                   . "/installer/data/$info{dbms}/en/marcflavour";
-                opendir( MYDIR, $dir )
+                opendir( $dir_h, $dir )
                   or warn "cannot open English MARC frameworks directory $dir";
             }
         }
-        my @listdir = grep { !/^\./ && -d "$dir/$_" } readdir(MYDIR);
-        closedir MYDIR;
+        my @listdir = grep { !/^\./ && -d "$dir/$_" } readdir($dir_h);
+        closedir $dir_h;
         my $marcflavour = C4::Context->preference("marcflavour");
         my @flavourlist;
         foreach my $marc (@listdir) {
@@ -416,10 +417,12 @@ elsif ( $step && $step == 3 ) {
           or die "Cannot open log file $logfilepath_errors: $!";
         @report = <$fh>;
         close $fh;
+        my $update_errors;
         if (@report) {
             $template->param( update_errors =>
                   [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ]
             );
+            $update_errors = 1;
             $template->param( has_update_errors => 1 );
             warn
 "The following errors were returned while attempting to run the updatedatabase.pl script:\n";
@@ -429,12 +432,22 @@ elsif ( $step && $step == 3 ) {
             eval { `rm $logfilepath_errors` };
         }
 
-        my $db_entries = get_db_entries();
-        my $report = update( $db_entries );
-
-        $template->param( success => $report->{success}, error => $report->{error} );
+        unless ( $update_errors ) {
+            my $db_entries = get_db_entries();
+            my $report = update( $db_entries );
+            my $atomic_update_files = get_atomic_updates;
+            my $atomic_update_report = run_atomic_updates( $atomic_update_files );
+
+            $template->param(
+                success        => $report->{success},
+                error          => $report->{error},
+                atomic_updates => {
+                    success => $atomic_update_report->{success},
+                    error   => $atomic_update_report->{error}
+                }
+            );
+        }
 
-        #warn "The following errors were returned while attempting to run the updatedatabase.pl script:\n"; #FIXME restore this
         $template->param( $op => 1 );
     }
     else {