[+] CORE : Add version_compare tools to align version sent with alignVersionNumber method.
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16135 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -2108,6 +2108,22 @@ FileETag INode MTime Size
|
|||||||
return $filtered_files;
|
return $filtered_files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Align version sent and use internal function
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @param $v1
|
||||||
|
* @param $v2
|
||||||
|
* @param string $operator
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function version_compare($v1, $v2, $operator = '<')
|
||||||
|
{
|
||||||
|
Tools::alignVersionNumber($v1, $v2);
|
||||||
|
return version_compare($v1, $v2, $operator);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Align 2 version with the same number of sub version
|
* Align 2 version with the same number of sub version
|
||||||
* version_compare will work better for its comparison :)
|
* version_compare will work better for its comparison :)
|
||||||
|
|||||||
@@ -381,9 +381,8 @@ abstract class ModuleCore
|
|||||||
public static function needUpgrade($module)
|
public static function needUpgrade($module)
|
||||||
{
|
{
|
||||||
self::$modules_cache[$module->name]['upgrade']['upgraded_from'] = $module->database_version;
|
self::$modules_cache[$module->name]['upgrade']['upgraded_from'] = $module->database_version;
|
||||||
Tools::alignVersionNumber($module->version, $module->database_version);
|
|
||||||
// Check the version of the module with the registered one and look if any upgrade file exist
|
// Check the version of the module with the registered one and look if any upgrade file exist
|
||||||
return version_compare($module->version, $module->database_version, '>')
|
return Tools::version_compare($module->version, $module->database_version, '>')
|
||||||
&& Module::loadUpgradeVersionList($module->name, $module->version, $module->database_version);
|
&& Module::loadUpgradeVersionList($module->name, $module->version, $module->database_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,12 +411,10 @@ abstract class ModuleCore
|
|||||||
{
|
{
|
||||||
$tab = explode('-', $file);
|
$tab = explode('-', $file);
|
||||||
$file_version = basename($tab[1], '.php');
|
$file_version = basename($tab[1], '.php');
|
||||||
Tools::alignVersionNumber($file_version, $module_version);
|
|
||||||
Tools::alignVersionNumber($file_version, $registered_version);
|
|
||||||
// Compare version, if minor than actual, we need to upgrade the module
|
// Compare version, if minor than actual, we need to upgrade the module
|
||||||
if (count($tab) == 2 &&
|
if (count($tab) == 2 &&
|
||||||
(version_compare($file_version, $module_version, '<=') &&
|
(Tools::version_compare($file_version, $module_version, '<=') &&
|
||||||
version_compare($file_version, $registered_version, '>')))
|
Tools::version_compare($file_version, $registered_version, '>')))
|
||||||
{
|
{
|
||||||
$list[] = array(
|
$list[] = array(
|
||||||
'file' => $upgrade_path.$file,
|
'file' => $upgrade_path.$file,
|
||||||
|
|||||||
Reference in New Issue
Block a user