Skip to content

Commit

Permalink
Item13551: Adjust the dependency comparison order
Browse files Browse the repository at this point in the history
VERSION comparison should be prioritized, and only fall back to RELEASE
if the request requires it.

This code should probably be redesigned.  But the unit tests all pass
without modification, and configure finds the right extensions now.
  • Loading branch information
gac410 committed Jul 23, 2015
1 parent f8e82ff commit 994aaee
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 16 deletions.
59 changes: 44 additions & 15 deletions core/lib/Foswiki/Configure/Dependency.pm
Expand Up @@ -299,12 +299,12 @@ sub compare_versions {
my $this = shift;
if ( $this->{type} eq 'perl' ) {

#print STDERR "Comparing TYPE PERL\n";
#print STDERR "Comparing TYPE PERL $this->{module}\n" if $this->{module};
return $this->_compare_extension_versions(@_);
}
else {

#print STDERR "Comparing TYPE cpan\n";
#print STDERR "Comparing TYPE cpan $this->{module}\n";
return $this->_compare_cpan_versions(@_);
}
}
Expand Down Expand Up @@ -461,31 +461,60 @@ sub _compare_extension_versions {
my $baseType = ''; # Type of version/release string for this module
my $reqType = ''; # Type of version/release string requested

if ( defined $aRELEASE ) {
unless ( defined $reqVer ) {

#print STDERR "Release $aRELEASE defined\n";
( $baseType, @atuple ) = _decodeReleaseString($aRELEASE);
#print STDERR "Comparison not defined\n";
return 0;
}
elsif ( defined $aVERSION ) {

# for some reason, no Release defined, fall back to the Version.
( $reqType, @btuple ) = _decodeReleaseString($reqVer);

#print STDERR "WANT TO COMPARE TO $reqType\n";

# Try version first. If it's a svn string, then need to try release
if ( defined $aVERSION ) {

#print STDERR "Version $aVERSION defined\n";
( $baseType, @atuple ) =
_decodeReleaseString($aVERSION); # if defined $aVERSION;
}
else {

#print STDERR "Neither RELEASE or VERSION defined\n";
return 0;
#print STDERR "VERSION decoded to $baseType\n" if ($baseType);
unless ( defined $aVERSION ) {
if ( defined $aRELEASE ) {

#print STDERR "Version undef, $aRELEASE defined\n";
( $baseType, @atuple ) = _decodeReleaseString($aRELEASE);
}
}
if ( $baseType eq 'svn' ) {
unless ( $reqType eq 'svn' ) {

unless ( defined $reqVer ) {
# Inconsistent VERSION, so try RELEASE
if ( defined $aRELEASE ) {

#print STDERR "Comparison not defined\n";
return 0;
#print STDERR "Release $aRELEASE defined\n";
( $baseType, @atuple ) = _decodeReleaseString($aRELEASE);
}
}
}

( $reqType, @btuple ) = _decodeReleaseString($reqVer);
if ( $reqType eq 'date' ) {
unless ( $baseType eq 'date' ) {

# Inconsistent VERSION, so try RELEASE
if ( defined $aRELEASE ) {

#print STDERR "Release $aRELEASE defined\n";
( $baseType, @atuple ) = _decodeReleaseString($aRELEASE);
}
}
}
unless ($baseType) {

#print STDERR "Unable to determine what to compare.\n";
return 0;
}

#print STDERR "EXPECT $baseType $string_op BEXPECT $reqType \n";

Expand Down Expand Up @@ -546,7 +575,7 @@ sub _compare_extension_versions {
my $comparison = "'$a' $string_op '$b'";
my $result = eval($comparison);

#print "[$comparison]->$result\n";
#print STDERR "[$comparison]->$result\n";
return $result;
}

Expand Down
2 changes: 1 addition & 1 deletion core/lib/Foswiki/Configure/Wizards/ExploreExtensions.pm
Expand Up @@ -367,7 +367,7 @@ CHECKBOXES
# pseudo-installed
$status = ' _is pseudo-installed_ ';
}
elsif ( $ext->compare_versions( '<', $ext->{release} ) ) {
elsif ( $ext->compare_versions( '<', $ext->{version} ) ) {

# Installed version is < available version

Expand Down

0 comments on commit 994aaee

Please sign in to comment.