Bugzilla – Attachment 66374 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
bug15562-Use-do-rather-than-system-to-execute-upda.patch (text/plain), 4.15 KB, created by
Srdjan Jankovic
on 2017-08-23 01:58:25 UTC
(
hide
)
Description:
[SIGNED-OFF] bug_15562: Use do() rather than system() to execute updatedatabase.pl from installer.pl
Filename:
MIME Type:
Creator:
Srdjan Jankovic
Created:
2017-08-23 01:58:25 UTC
Size:
4.15 KB
patch
obsolete
>From b77d03fdeea4cd1dd244f067de5d3ab199f2743a Mon Sep 17 00:00:00 2001 >From: Srdjan <srdjan@catalyst.net.nz> >Date: Wed, 10 Feb 2016 15:47:25 +1300 >Subject: [PATCH] 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 | 54 +++++++++++++++++++++------------------- > 2 files changed, 33 insertions(+), 26 deletions(-) > >diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm >index c4f5409..d2e3254 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 ac43214..b89abb6 100755 >--- a/installer/install.pl >+++ b/installer/install.pl >@@ -24,6 +24,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; >@@ -388,40 +389,41 @@ elsif ( $step && $step == 3 ) { > chk_log( $logdir, "updatedatabase-error_$filename_suffix" ) > ); > >- my $cmd = C4::Context->config("intranetdir") >- . "/installer/data/$info{dbms}/updatedatabase.pl >> $logfilepath 2>> $logfilepath_errors"; >+ my $script = C4::Context->config("intranetdir") . "/installer/data/$info{dbms}/updatedatabase.pl"; >+ my ($stdout, $stderr, $exit) = capture { do( $script ) }; >+ warn "Cannot execute $script: ".($@ || $!) if $@ || $!; > >- system($cmd ); >- >- 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 ) ) ] >- ); >+ 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 "The following errors were returned while attempting to run the updatedatabase.pl script:\n"; >+ warn $_ foreach @errors; > } > else { >- eval { `rm $logfilepath_errors` }; >+# eval { `rm $logfilepath_errors` }; > } > $template->param( $op => 1 ); > } >-- >2.7.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