Lines 7-12
use diagnostics;
Link Here
|
7 |
use C4::InstallAuth; |
7 |
use C4::InstallAuth; |
8 |
use CGI qw ( -utf8 ); |
8 |
use CGI qw ( -utf8 ); |
9 |
use POSIX qw(strftime); |
9 |
use POSIX qw(strftime); |
|
|
10 |
use Capture::Tiny qw(capture); |
10 |
|
11 |
|
11 |
use C4::Context; |
12 |
use C4::Context; |
12 |
use C4::Output; |
13 |
use C4::Output; |
Lines 332-361
elsif ( $step && $step == 3 ) {
Link Here
|
332 |
my $filename_suffix = join '_', $now, $dbversion, $kohaversion; |
333 |
my $filename_suffix = join '_', $now, $dbversion, $kohaversion; |
333 |
my ( $logfilepath, $logfilepath_errors ) = ( chk_log($logdir, "updatedatabase_$filename_suffix"), chk_log($logdir, "updatedatabase-error_$filename_suffix") ); |
334 |
my ( $logfilepath, $logfilepath_errors ) = ( chk_log($logdir, "updatedatabase_$filename_suffix"), chk_log($logdir, "updatedatabase-error_$filename_suffix") ); |
334 |
|
335 |
|
335 |
my $cmd = C4::Context->config("intranetdir") . "/installer/data/$info{dbms}/updatedatabase.pl >> $logfilepath 2>> $logfilepath_errors"; |
|
|
336 |
|
336 |
|
337 |
system($cmd ); |
337 |
my $script = C4::Context->config("intranetdir") . "/installer/data/$info{dbms}/updatedatabase.pl"; |
338 |
|
338 |
|
339 |
my $fh; |
339 |
my ($stdout, $stderr, $exit) = capture { do( $script ) }; |
340 |
open( $fh, "<", $logfilepath ) or die "Cannot open log file $logfilepath: $!"; |
340 |
warn "Cannot execute $script: ".($@ || $!); |
341 |
my @report = <$fh>; |
341 |
|
342 |
close $fh; |
342 |
if ($stdout) { |
343 |
if (@report) { |
343 |
if ( open( my $fh, ">>", $logfilepath ) ) { |
344 |
$template->param( update_report => [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ] ); |
344 |
print $fh $stdout; |
|
|
345 |
close $fh; |
346 |
} |
347 |
else { |
348 |
warn "Cannot open log file $logfilepath: $!"; |
349 |
} |
350 |
$template->param( update_report => [ map { line => $_ }, split( /\n/, $stdout ) ] ); |
345 |
$template->param( has_update_succeeds => 1 ); |
351 |
$template->param( has_update_succeeds => 1 ); |
346 |
} else { |
352 |
} else { |
347 |
eval{ `rm $logfilepath` }; |
353 |
# eval{ `rm $logfilepath` }; |
348 |
} |
354 |
} |
349 |
open( $fh, "<", $logfilepath_errors ) or die "Cannot open log file $logfilepath_errors: $!"; |
355 |
|
350 |
@report = <$fh>; |
356 |
if ($stderr) { |
351 |
close $fh; |
357 |
if ( open( my $fh, ">>", $logfilepath_errors ) ) { |
352 |
if (@report) { |
358 |
print $fh $stderr; |
353 |
$template->param( update_errors => [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ] ); |
359 |
close $fh; |
|
|
360 |
} |
361 |
else { |
362 |
warn "Cannot open log file $logfilepath_errors: $!"; |
363 |
} |
364 |
my @errors = split( /\n/, $stderr ); |
365 |
$template->param( update_errors => [ map { line => $_ }, @errors ] ); |
354 |
$template->param( has_update_errors => 1 ); |
366 |
$template->param( has_update_errors => 1 ); |
355 |
warn "The following errors were returned while attempting to run the updatedatabase.pl script:\n"; |
367 |
warn "The following errors were returned while attempting to run the updatedatabase.pl script:\n"; |
356 |
foreach my $line (@report) { warn "$line\n"; } |
368 |
warn $_ foreach @errors; |
357 |
} else { |
369 |
} else { |
358 |
eval{ `rm $logfilepath_errors` }; |
370 |
# eval{ `rm $logfilepath_errors` }; |
359 |
} |
371 |
} |
360 |
$template->param( $op => 1 ); |
372 |
$template->param( $op => 1 ); |
361 |
} |
373 |
} |
362 |
- |
|
|