SMF Development > Fixed or Bogus Bugs

2.0 RC5 Function matchPackageVersion(): only allows one interval

(1/7) > >>

davidhs:
Function matchPackageVersion() only allows one interval, i.e.

--- Quote ---matchPackageVersion('3.0.5', '3.0, 3.0.4-3.0.6') => MATCH
matchPackageVersion('3.0.5', '3.0, 3.0.2-3.0.3, 3.0.4-3.0.6') => NO MATCH
--- End quote ---


Version SMF: 2.0 RC5 and lower
File: Sources/Subs-Package.php
Function: matchPackageVersion()
Line: 1468
Code:

--- Code: --- $lower = explode('.', $lower);
$upper = explode('.', $upper);
$version = explode('.', $version);

foreach ($upper as $key => $high)
{
// Let's check that this is at or below the upper... obviously.
if (isset($version[$key]) && trim($version[$key]) > trim($high))
return false;

// OK, let's check it's above the lower key... if it exists!
if (isset($lower[$key]))
{
// The version either needs to have something here (i.e. can't be 1.0 on a 1.0.11) AND needs to be greater or equal to.
// Note that if it's a range lower[key] might be blank, in that case version can not be set!
if (!empty($lower[$key]) && (!isset($version[$key]) || trim($version[$key]) < trim($lower[$key])))
return false;
}
}
return true;
--- End code ---
Must be:

--- Code: --- $lower_array = explode('.', $lower);
$upper_array = explode('.', $upper);
$version_array = explode('.', $version);

// Upper must be something, else version can not be set!
if (!$upper_array)
continue; // Continue in foreach $for.

foreach ($upper_array as $key => $high)
{
// Version must be something, else can not be set!
if (!isset($version_array[$key]))
continue 2; // Exit foreach $upper and continue in foreach $for.

// Let's check that this is at or below the upper... obviously.
if (trim($version_array[$key]) > trim($high))
continue 2; // Exit foreach $upper and continue in foreach $for.

// Lower must be something, else version can not be set!
// (i.e 1.0-1.0.3 not is valid; 1.0,1.0.1-1.0.3 is valid)
if (!isset($lower_array[$key]) || (empty($lower_array[$key]) && !is_numeric($lower_array[$key])))
continue 2; // Exit foreach $upper and continue in foreach $for.

// Let's check that this is at or upper the lower... obviously.
if (trim($version_array[$key]) < trim($lower_array[$key]))
continue 2; // Exit foreach $upper and continue in foreach $for.
}

// All keys of version match between lower and upper
return true;
--- End code ---

Examples:

--- Quote ---original matchPackageVersion('3.0.5', '3.0, 3.0.4-3.0.6') => MATCH
new matchPackageVersion('3.0.5', '3.0, 3.0.4-3.0.6') => MATCH

original matchPackageVersion('3.0.5', '3.0, 3.0.2-3.0.3, 3.0.4-3.0.6') => NO MATCH
new matchPackageVersion('3.0.5', '3.0, 3.0.2-3.0.3, 3.0.4-3.0.6') => MATCH
--- End quote ---

Arantor:
Incidentally what happens if you use 3.0 RC2 - 3.0 RC4 rather than 3.0 RC2-3.0RC4 (noting the difference in spaces)?

davidhs:
This is the same. It use trim() function to remove spaces.

i.e. you can write:
v1,v2    ,    v3    -v4
but no
v1, v2, v3-v4, v5-v6
(and this is correct!)

Edit: 2.0RC4 (without spaces) not is correct name of version). The correct is 2.0 RC4. trim() function only is used in text between version, not in name of version.

Arantor:
Spaces in the middle of strings?

davidhs:

--- Quote from: Arantor on February 10, 2011, 07:41:44 AM ---Spaces in the middle of strings?

--- End quote ---
Like example above (I edit my last replay)

Navigation

[0] Message Index

[#] Next page

Go to full version