// Merge -> revision 8123
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8125 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+9
-13
@@ -572,28 +572,24 @@ abstract class ModuleCore
|
||||
$modulesNameToCursor = array();
|
||||
$errors = array();
|
||||
$modules_dir = self::getModulesDirOnDisk();
|
||||
|
||||
$memory_limit = Tools::getMemoryLimit();
|
||||
|
||||
foreach ($modules_dir AS $module)
|
||||
{
|
||||
// Memory usage checking
|
||||
if ($memory_limit = strtoupper(@ini_get('memory_limit')))
|
||||
if (function_exists('memory_get_usage') && $memory_limit !== -1)
|
||||
{
|
||||
if (strpos($memory_limit, 'M'))
|
||||
{
|
||||
$memory_limit = str_replace('M', '', $memory_limit);
|
||||
$memory_limit *= 1024 * 1024;
|
||||
}
|
||||
elseif (strpos($memory_limit, 'K'))
|
||||
{
|
||||
$memory_limit = str_replace('K', '', $memory_limit);
|
||||
$memory_limit *= 1024;
|
||||
}
|
||||
|
||||
if ($memory_limit - memory_get_usage() <= (512 * 1024))
|
||||
$current_memory = memory_get_usage(true);
|
||||
// memory_threshold in MB
|
||||
$memory_threshold = (Tools::isX86_64arch() ? 3 : 1.5);
|
||||
if (($memory_limit - $current_memory) <= ($memory_threshold * 1024 * 1024))
|
||||
{
|
||||
$errors[] = Tools::displayError('All modules cannot be loaded due to memory limit restriction reason, please increase your memory_limit value on your server configuration');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$configFile = _PS_MODULE_DIR_.$module.'/config.xml';
|
||||
$xml_exist = file_exists($configFile);
|
||||
if ($xml_exist)
|
||||
|
||||
@@ -2038,6 +2038,33 @@ FileETag INode MTime Size
|
||||
else
|
||||
$smarty->clear_all_cache();
|
||||
}
|
||||
|
||||
/**
|
||||
* getMemoryLimit allow to get the memory limit in octet
|
||||
*
|
||||
* @since 1.4.5.0
|
||||
* @return int the memory limit value in octet
|
||||
*/
|
||||
public static function getMemoryLimit()
|
||||
{
|
||||
$memory_limit = @ini_get('memory_limit');
|
||||
|
||||
if (preg_match('/[0-9]+k/i', $memory_limit))
|
||||
return 1024 * (int)$memory_limit;
|
||||
|
||||
if (preg_match('/[0-9]+m/i', $memory_limit))
|
||||
return 1024 * 1024 * (int)$memory_limit;
|
||||
|
||||
if (preg_match('/[0-9]+g/i', $memory_limit))
|
||||
return 1024 * 1024 * 1024 * (int)$memory_limit;
|
||||
|
||||
return $memory_limit;
|
||||
}
|
||||
|
||||
public static function isX86_64arch()
|
||||
{
|
||||
return (PHP_INT_MAX == '9223372036854775807');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user