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