Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into development

This commit is contained in:
gRoussac
2013-11-04 18:27:39 +01:00
3 changed files with 18 additions and 17 deletions
+9 -15
View File
@@ -137,24 +137,18 @@ class Autoload
// Write classes index on disc to cache it
$filename = $this->root_dir.Autoload::INDEX_FILE;
if ((file_exists($filename) && !is_writable($filename)) || !is_writable(dirname($filename)))
$filename_tmp = tempnam(dirname($filename), basename($filename.'.'));
if ($filename_tmp !== false && file_put_contents($filename_tmp, $content, LOCK_EX) !== false)
{
header('HTTP/1.1 503 temporarily overloaded');
// Cannot use PrestaShopException in this context
die('/cache/class_index.php is not writable, please give write permissions (chmod 666) on this file.');
}
else
{
$filename_tmp = tempnam(dirname($filename), basename($filename.'.'));
if($filename_tmp !== FALSE and file_put_contents($filename_tmp, $content, LOCK_EX) !== FALSE)
{
@rename($filename_tmp, $filename);
@chmod($filename, 0666);
}
if (!rename($filename_tmp, $filename))
unlink($filename_tmp);
else
// $filename_tmp couldn't be written. $filename should be there anyway (even if outdated), no need to die.
error_log('Cannot write temporary file '.$filename_tmp);
@chmod($filename, 0666);
}
// $filename_tmp couldn't be written. $filename should be there anyway (even if outdated), no need to die.
else
error_log('Cannot write temporary file '.$filename_tmp);
$this->index = $classes;
}
+6 -2
View File
@@ -390,6 +390,10 @@ class HookCore extends ObjectModel
*/
public static function exec($hook_name, $hook_args = array(), $id_module = null, $array_return = false, $check_exceptions = true)
{
static $disable_non_native_modules = null;
if ($disable_non_native_modules === null)
$disable_non_native_modules = (bool)Configuration::get('PS_DISABLE_NON_NATIVE_MODULE');
// Check arguments validity
if (($id_module && !is_numeric($id_module)) || !Validate::isHookName($hook_name))
throw new PrestaShopException('Invalid id_module or hook_name');
@@ -419,7 +423,7 @@ class HookCore extends ObjectModel
$altern = 0;
$output = '';
if (!isset(Hook::$native_module))
if ($disable_non_native_modules && !isset(Hook::$native_module))
Hook::$native_module = Module::getNativeModuleList();
foreach ($module_list as $array)
@@ -428,7 +432,7 @@ class HookCore extends ObjectModel
if ($id_module && $id_module != $array['id_module'])
continue;
if ((bool)Configuration::get('PS_DISABLE_NON_NATIVE_MODULE') && !in_array($array['module'], self::$native_module))
if ((bool)$disable_non_native_modules && Hook::$native_module && count(Hook::$native_module) && !in_array($array['module'], self::$native_module))
continue;
if (!($moduleInstance = Module::getInstanceByName($array['module'])))
+3
View File
@@ -1296,6 +1296,9 @@ abstract class ModuleCore
public static function getNativeModuleList()
{
$module_list_xml = _PS_ROOT_DIR_.self::CACHE_FILE_MODULES_LIST;
if (!file_exists($module_list_xml))
return false;
$native_modules = simplexml_load_file($module_list_xml);
$native_modules = $native_modules->modules;
$modules = array();