Bugzilla – Attachment 50713 Details for
Bug 15562
Make Koha more suitable for shared hosting with plack
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] bug_15562: Use do() rather than system() to execute updatedatabase.pl from installer.pl
SIGNED-OFF-bug15562-Use-do-rather-than-system-to-e.patch (text/plain), 4.08 KB, created by
Kyle M Hall (khall)
on 2016-04-26 11:22:12 UTC
(
hide
)
Description:
[SIGNED-OFF] bug_15562: Use do() rather than system() to execute updatedatabase.pl from installer.pl
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-04-26 11:22:12 UTC
Size:
4.08 KB
patch
obsolete
>From 409a814bb255c364031c6b342f3e81d502955d42 Mon Sep 17 00:00:00 2001 >From: Srdjan <srdjan@catalyst.net.nz> >Date: Wed, 10 Feb 2016 15:47:25 +1300 >Subject: [PATCH] [SIGNED-OFF] bug_15562: Use do() rather than system() to > execute updatedatabase.pl from installer.pl > >That way: >* no external process is spawned >* code executes in the same perl process, which is required for plack > multi-site > >I have a dream. A dream that one day all code from .pl's will be in some >.pm's. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/Installer/PerlDependencies.pm | 5 +++++ > installer/install.pl | 44 +++++++++++++++++++++++++--------------- > 2 files changed, 33 insertions(+), 16 deletions(-) > >diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm >index 09dafc4..96f6afb 100644 >--- a/C4/Installer/PerlDependencies.pm >+++ b/C4/Installer/PerlDependencies.pm >@@ -362,6 +362,11 @@ our $PERL_DEPS = { > 'required' => '1', > 'min_ver' => '0.46' > }, >+ 'Capture::Tiny' => { >+ 'usage' => 'Core', >+ 'required' => '1', >+ 'min_ver' => '0.08' >+ }, > 'HTTP::Cookies' => { > 'usage' => 'Core', > 'required' => '1', >diff --git a/installer/install.pl b/installer/install.pl >index cc67557..e84d88b 100755 >--- a/installer/install.pl >+++ b/installer/install.pl >@@ -7,6 +7,7 @@ use diagnostics; > use C4::InstallAuth; > use CGI qw ( -utf8 ); > use POSIX qw(strftime); >+use Capture::Tiny qw(capture); > > use C4::Context; > use C4::Output; >@@ -332,30 +333,41 @@ elsif ( $step && $step == 3 ) { > my $filename_suffix = join '_', $now, $dbversion, $kohaversion; > my ( $logfilepath, $logfilepath_errors ) = ( chk_log($logdir, "updatedatabase_$filename_suffix"), chk_log($logdir, "updatedatabase-error_$filename_suffix") ); > >- my $cmd = C4::Context->config("intranetdir") . "/installer/data/$info{dbms}/updatedatabase.pl >> $logfilepath 2>> $logfilepath_errors"; > >- system($cmd ); >+ my $script = C4::Context->config("intranetdir") . "/installer/data/$info{dbms}/updatedatabase.pl"; > >- my $fh; >- open( $fh, "<", $logfilepath ) or die "Cannot open log file $logfilepath: $!"; >- my @report = <$fh>; >- close $fh; >- if (@report) { >- $template->param( update_report => [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ] ); >+ my ($stdout, $stderr, $exit) = capture { do( $script ) }; >+ warn "Cannot execute $script: ".($@ || $!); >+ >+ if ($stdout) { >+ if ( open( my $fh, ">>", $logfilepath ) ) { >+ print $fh $stdout; >+ close $fh; >+ } >+ else { >+ warn "Cannot open log file $logfilepath: $!"; >+ } >+ $template->param( update_report => [ map { line => $_ }, split( /\n/, $stdout ) ] ); > $template->param( has_update_succeeds => 1 ); > } else { >- eval{ `rm $logfilepath` }; >+# eval{ `rm $logfilepath` }; > } >- open( $fh, "<", $logfilepath_errors ) or die "Cannot open log file $logfilepath_errors: $!"; >- @report = <$fh>; >- close $fh; >- if (@report) { >- $template->param( update_errors => [ map { { line => $_ } } split( /\n/, join( '', @report ) ) ] ); >+ >+ if ($stderr) { >+ if ( open( my $fh, ">>", $logfilepath_errors ) ) { >+ print $fh $stderr; >+ close $fh; >+ } >+ else { >+ warn "Cannot open log file $logfilepath_errors: $!"; >+ } >+ my @errors = split( /\n/, $stderr ); >+ $template->param( update_errors => [ map { line => $_ }, @errors ] ); > $template->param( has_update_errors => 1 ); > warn "The following errors were returned while attempting to run the updatedatabase.pl script:\n"; >- foreach my $line (@report) { warn "$line\n"; } >+ warn $_ foreach @errors; > } else { >- eval{ `rm $logfilepath_errors` }; >+# eval{ `rm $logfilepath_errors` }; > } > $template->param( $op => 1 ); > } >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15562
:
47420
|
47421
|
47422
|
47838
|
47944
|
47945
|
47946
|
47947
|
49370
|
49371
|
49372
|
49373
|
49664
|
49665
|
49666
|
49667
|
49709
|
50702
|
50703
|
50713
|
50714
|
50715
|
50716
|
50870
|
51939
|
51940
|
53296
|
53297
|
55577
|
55578
|
60723
|
60724
|
60725
|
60726
|
66374
|
66375
|
66376
|
66377
|
76062