Skip to content

Commit

Permalink
Item14203: Skipping optional modules on the first run.
Browse files Browse the repository at this point in the history
- Fixed use of undefined capture file content.
  • Loading branch information
vrurg committed Nov 8, 2016
1 parent f426524 commit 62c271b
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions core/lib/Foswiki/Aux/Dependencies.pm
Expand Up @@ -155,6 +155,7 @@ sub import {
rootDir => $rootDir,
doUpgrade => 0,
inlineExec => $noPerlBin,
firstRunCheck => 1,
);
if ( defined $params{requiredExtensions} ) {
if ( ref( $params{requiredExtensions} ) eq 'ARRAY' ) {
Expand Down Expand Up @@ -270,7 +271,7 @@ sub checkDependencies {
}

# Dependencies must be rechecked.
return 0 unless installDependencies( \%profile );
return 0 unless _installDependencies( \%profile );
writeChecksums( \%profile );
return 1;
}
Expand Down Expand Up @@ -635,6 +636,8 @@ sub _muteExec {
my $profile = shift;
my $sub = shift;

my $wantArray = wantarray;

my $rc;
my $outFile = File::Spec->catfile( $profile->{libDir}, ".stdout" );
my $errFile = File::Spec->catfile( $profile->{libDir}, ".stderr" );
Expand All @@ -648,13 +651,20 @@ sub _muteExec {
$rc = $muter->exec( $sub, @_ );
}

my $out = _slurpFile($outFile);
my $err = _slurpFile($errFile);
my @capturedContent;

if ($wantArray) {
foreach my $captureFile ( $outFile, $errFile ) {
push @capturedContent,
_slurpFile($captureFile)
// '*** Failed to slurp from ' . $captureFile . ': ' . $!;
}
}

unlink $outFile;
unlink $errFile;

return wantarray ? ( $rc, $out, $err ) : $rc;
return $wantArray ? ( $rc, @capturedContent ) : $rc;
}

sub _testModule {
Expand Down Expand Up @@ -757,7 +767,7 @@ sub _verifyModule {
return 1;
}

sub installDependencies {
sub _installDependencies {
my $profile = shift;

unless ( -d $profile->{libDir} ) {
Expand Down Expand Up @@ -787,6 +797,9 @@ sub installDependencies {
my $extOptional = !( $extName && $profile->{mandatoryExt}{$extName} );
my $optional = ( $depEntry->{fromExt} && $extOptional )
|| $depEntry->{description} !~ /^required/i;

# To reduce the first time startup time we ignore optional dependencies.
next if $optional && $profile->{firstRunCheck};

_dbg("Checking for $depEntry->{module} from $depEntry->{source}");

Expand Down

0 comments on commit 62c271b

Please sign in to comment.