Skip to content

Commit

Permalink
Merge pull request #669 from Spuds/pkg
Browse files Browse the repository at this point in the history
Fix a couple of items in the package manager

Just to test the irc bot.
  • Loading branch information
emanuele45 committed Jul 14, 2013
2 parents e3e87b5 + c1e5f15 commit 4e04cb1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion sources/admin/Packages.php
Expand Up @@ -537,7 +537,7 @@ public function action_install()
else
{
// See if this dependency is installed
$installed_version = checkPackageDependency();
$installed_version = checkPackageDependency($action['id']);

// Do a version level check (if requested) in the most basic way
$version_check = (isset($action['version']) ? $installed_version == $action['version'] : true);
Expand Down
33 changes: 17 additions & 16 deletions sources/subs/Package.subs.php
Expand Up @@ -1482,12 +1482,12 @@ function matchHighestPackageVersion($versions, $reset = false, $the_version)
if ($reset)
$near_version = 0;

// Normalize the $versions while we remove our previous Doh!
$versions = explode(',', str_replace(array(' ', '2.0rc1-1'), array('', '2.0rc1.1'), strtolower($versions)));
// Normalize the $versions
$versions = explode(',', str_replace(' ', '', strtolower($versions)));

// Adjust things higher even though the starting number is lower so we pick up the right (latest) version
list($the_brand,) = explode(' ', $forum_version, 2);
if ($the_brand = 'ElkArte')
if ($the_brand == 'ElkArte')
$the_version = '1' . $the_version;

// Loop through each version, save the highest we can find
Expand All @@ -1497,9 +1497,9 @@ function matchHighestPackageVersion($versions, $reset = false, $the_version)
if (strpos($for, '*') !== false)
$for = str_replace('*', '0dev0', $for) . '-' . str_replace('*', '999', $for);

// If we have a range, grab the lower value, done this way so it looks normal-er to the user e.g. 2.0 vs 2.0.99
// If we have a range, grab the lower value, done this way so it looks normal-er to the user e.g. 1.0 vs 1.0.99
if (strpos($for, '-') !== false)
list ($for, $higher) = explode('-', $for);
list ($for,) = explode('-', $for);

// Do the compare, if the for is greater, than what we have but not greater than what we are running .....
if (compareVersions($near_version, $for) === -1 && compareVersions($for, $the_version) !== 1)
Expand All @@ -1521,9 +1521,9 @@ function matchHighestPackageVersion($versions, $reset = false, $the_version)
*/
function matchPackageVersion($version, $versions)
{
// Make sure everything is lowercase and clean of spaces and unpleasant history.
$version = str_replace(array(' ', '2.0rc1-1'), array('', '2.0rc1.1'), strtolower($version));
$versions = explode(',', str_replace(array(' ', '2.0rc1-1'), array('', '2.0rc1.1'), strtolower($versions)));
// Make sure everything is lowercase and clean of spaces.
$version = str_replace(' ', '', strtolower($version));
$versions = explode(',', str_replace(' ', '', strtolower($versions)));

// Perhaps we do accept anything?
if (in_array('all', $versions))
Expand Down Expand Up @@ -1571,7 +1571,7 @@ function compareVersions($version1, $version2)
foreach (array(1 => $version1, $version2) as $id => $version)
{
// Clean the version and extract the version parts.
$clean = str_replace(array(' ', '2.0rc1-1'), array('', '2.0rc1.1'), strtolower($version));
$clean = str_replace(' ', '', strtolower($version));
preg_match('~(\d+)(?:\.(\d+|))?(?:\.)?(\d+|)(?:(alpha|beta|rc)(\d+|)(?:\.)?(\d+|))?(?:(dev))?(\d+|)~', $clean, $parts);

// Build an array of parts.
Expand Down Expand Up @@ -3220,11 +3220,11 @@ function isPackageInstalled($id)
$db = database();

$result = array(
'package_id' => '',
'install_state' => '',
'old_themes' => '',
'old_version' => '',
'db_changes' => ''
'package_id' => null,
'install_state' => null,
'old_themes' => null,
'old_version' => null,
'db_changes' => null
);

if (empty($id))
Expand Down Expand Up @@ -3291,8 +3291,9 @@ function setPackageState($id)
/**
* Checks if a package is installed, and if so returns its version level
*
* @param string $id
*/
function checkPackageDependency()
function checkPackageDependency($id)
{
$db = database();

Expand All @@ -3307,7 +3308,7 @@ function checkPackageDependency()
LIMIT 1',
array(
'not_installed' => 0,
'current_package' => $action['id'],
'current_package' => $id,
)
);
while ($row = $db->fetch_row($request));
Expand Down

0 comments on commit 4e04cb1

Please sign in to comment.