[-] BO : Fix bug #PSCFI-6902 fatal error when memcache not installed and Memcached previously activated
This commit is contained in:
1 parent
bf9b1de873
commit
d74f9c837b
3 files changed
+88
-74
No files matched your search
Vendored
+28
-22
@@ -46,26 +46,28 @@ class CacheMemcacheCore extends Cache
|
|||||||
|
|
||||||
// Get keys (this code comes from Doctrine 2 project)
|
// Get keys (this code comes from Doctrine 2 project)
|
||||||
$this->keys = array();
|
$this->keys = array();
|
||||||
$all_slabs = $this->memcache->getExtendedStats('slabs');
|
$servers = self::getMemcachedServers();
|
||||||
|
if(is_array($servers) && count($servers) > 0)
|
||||||
foreach ($all_slabs as $server => $slabs)
|
$all_slabs = $this->memcache->getExtendedStats('slabs');
|
||||||
{
|
if(isset($all_slabs) && is_array($all_slabs))
|
||||||
if (is_array($slabs))
|
foreach ($all_slabs as $server => $slabs)
|
||||||
{
|
{
|
||||||
foreach (array_keys($slabs) as $slab_id)
|
if (is_array($slabs))
|
||||||
{
|
{
|
||||||
$dump = $this->memcache->getExtendedStats('cachedump', (int)$slab_id);
|
foreach (array_keys($slabs) as $slab_id)
|
||||||
if ($dump)
|
{
|
||||||
{
|
$dump = $this->memcache->getExtendedStats('cachedump', (int)$slab_id);
|
||||||
foreach ($dump as $entries)
|
if ($dump)
|
||||||
{
|
{
|
||||||
if ($entries)
|
foreach ($dump as $entries)
|
||||||
$this->keys = array_merge($this->keys, array_keys($entries));
|
{
|
||||||
}
|
if ($entries)
|
||||||
}
|
$this->keys = array_merge($this->keys, array_keys($entries));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
@@ -78,8 +80,12 @@ class CacheMemcacheCore extends Cache
|
|||||||
*/
|
*/
|
||||||
public function connect()
|
public function connect()
|
||||||
{
|
{
|
||||||
$this->memcache = new Memcache();
|
if (class_exists('Memcache') && extension_loaded('memcache'))
|
||||||
$servers = CacheMemcache::getMemcachedServers();
|
$this->memcache = new Memcache();
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$servers = self::getMemcachedServers();
|
||||||
if (!$servers)
|
if (!$servers)
|
||||||
return false;
|
return false;
|
||||||
foreach ($servers as $server)
|
foreach ($servers as $server)
|
||||||
|
|||||||
@@ -2192,9 +2192,10 @@ class AdminControllerCore extends Controller
|
|||||||
$class_name = $this->className;
|
$class_name = $this->className;
|
||||||
|
|
||||||
/* Class specific validation rules */
|
/* Class specific validation rules */
|
||||||
$rules = call_user_func(array($class_name, 'getValidationRules'), $class_name);
|
if (!empty($class_name))
|
||||||
|
$rules = call_user_func(array($class_name, 'getValidationRules'), $class_name);
|
||||||
|
|
||||||
if ((count($rules['requiredLang']) || count($rules['sizeLang']) || count($rules['validateLang'])))
|
if (isset($rules) && count($rules) && (count($rules['requiredLang']) || count($rules['sizeLang']) || count($rules['validateLang'])))
|
||||||
{
|
{
|
||||||
/* Language() instance determined by default language */
|
/* Language() instance determined by default language */
|
||||||
$default_language = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
|
$default_language = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
|
||||||
@@ -2204,56 +2205,61 @@ class AdminControllerCore extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Checking for required fields */
|
/* Checking for required fields */
|
||||||
foreach ($rules['required'] as $field)
|
if (isset($rules['required']) && is_array($rules['required']))
|
||||||
if (($value = Tools::getValue($field)) == false && (string)$value != '0')
|
foreach ($rules['required'] as $field)
|
||||||
if (!Tools::getValue($this->identifier) || ($field != 'passwd' && $field != 'no-picture'))
|
if (($value = Tools::getValue($field)) == false && (string)$value != '0')
|
||||||
$this->errors[] = sprintf(
|
if (!Tools::getValue($this->identifier) || ($field != 'passwd' && $field != 'no-picture'))
|
||||||
Tools::displayError('The field %s is required.'),
|
$this->errors[] = sprintf(
|
||||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
Tools::displayError('The field %s is required.'),
|
||||||
);
|
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
||||||
|
);
|
||||||
|
|
||||||
/* Checking for multilingual required fields */
|
/* Checking for multilingual required fields */
|
||||||
foreach ($rules['requiredLang'] as $field_lang)
|
if (isset($rules['requiredLang']) && is_array($rules['requiredLang']))
|
||||||
if (($empty = Tools::getValue($field_lang.'_'.$default_language->id)) === false || $empty !== '0' && empty($empty))
|
foreach ($rules['requiredLang'] as $field_lang)
|
||||||
$this->errors[] = sprintf(
|
if (($empty = Tools::getValue($field_lang.'_'.$default_language->id)) === false || $empty !== '0' && empty($empty))
|
||||||
Tools::displayError('The field %1$s is required at least in %2$s.'),
|
$this->errors[] = sprintf(
|
||||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
Tools::displayError('The field %1$s is required at least in %2$s.'),
|
||||||
$default_language->name
|
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||||
);
|
$default_language->name
|
||||||
|
);
|
||||||
|
|
||||||
/* Checking for maximum fields sizes */
|
/* Checking for maximum fields sizes */
|
||||||
foreach ($rules['size'] as $field => $max_length)
|
if (isset($rules['size']) && is_array($rules['size']))
|
||||||
if (Tools::getValue($field) !== false && Tools::strlen(Tools::getValue($field)) > $max_length)
|
foreach ($rules['size'] as $field => $max_length)
|
||||||
$this->errors[] = sprintf(
|
if (Tools::getValue($field) !== false && Tools::strlen(Tools::getValue($field)) > $max_length)
|
||||||
Tools::displayError('The field %1$s is too long (%2$d chars max).'),
|
|
||||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name),
|
|
||||||
$max_length
|
|
||||||
);
|
|
||||||
|
|
||||||
/* Checking for maximum multilingual fields size */
|
|
||||||
foreach ($rules['sizeLang'] as $field_lang => $max_length)
|
|
||||||
foreach ($languages as $language)
|
|
||||||
{
|
|
||||||
$field_lang_value = Tools::getValue($field_lang.'_'.$language['id_lang']);
|
|
||||||
if ($field_lang_value !== false && Tools::strlen($field_lang_value) > $max_length)
|
|
||||||
$this->errors[] = sprintf(
|
$this->errors[] = sprintf(
|
||||||
Tools::displayError('The field %1$s (%2$s) is too long (%3$d chars max, html chars including).'),
|
Tools::displayError('The field %1$s is too long (%2$d chars max).'),
|
||||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name),
|
||||||
$language['name'],
|
|
||||||
$max_length
|
$max_length
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
/* Checking for maximum multilingual fields size */
|
||||||
|
if (isset($rules['sizeLang']) && is_array($rules['sizeLang']))
|
||||||
|
foreach ($rules['sizeLang'] as $field_lang => $max_length)
|
||||||
|
foreach ($languages as $language)
|
||||||
|
{
|
||||||
|
$field_lang_value = Tools::getValue($field_lang.'_'.$language['id_lang']);
|
||||||
|
if ($field_lang_value !== false && Tools::strlen($field_lang_value) > $max_length)
|
||||||
|
$this->errors[] = sprintf(
|
||||||
|
Tools::displayError('The field %1$s (%2$s) is too long (%3$d chars max, html chars including).'),
|
||||||
|
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||||
|
$language['name'],
|
||||||
|
$max_length
|
||||||
|
);
|
||||||
|
}
|
||||||
/* Overload this method for custom checking */
|
/* Overload this method for custom checking */
|
||||||
$this->_childValidation();
|
$this->_childValidation();
|
||||||
|
|
||||||
/* Checking for fields validity */
|
/* Checking for fields validity */
|
||||||
foreach ($rules['validate'] as $field => $function)
|
if (isset($rules['validate']) && is_array($rules['validate']))
|
||||||
if (($value = Tools::getValue($field)) !== false && ($field != 'passwd'))
|
foreach ($rules['validate'] as $field => $function)
|
||||||
if (!Validate::$function($value) && !empty($value))
|
if (($value = Tools::getValue($field)) !== false && ($field != 'passwd'))
|
||||||
$this->errors[] = sprintf(
|
if (!Validate::$function($value) && !empty($value))
|
||||||
Tools::displayError('The field %s is invalid.'),
|
$this->errors[] = sprintf(
|
||||||
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
Tools::displayError('The field %s is invalid.'),
|
||||||
);
|
call_user_func(array($class_name, 'displayFieldName'), $field, $class_name)
|
||||||
|
);
|
||||||
|
|
||||||
/* Checking for passwd_old validity */
|
/* Checking for passwd_old validity */
|
||||||
if (($value = Tools::getValue('passwd')) != false)
|
if (($value = Tools::getValue('passwd')) != false)
|
||||||
@@ -2271,15 +2277,16 @@ class AdminControllerCore extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Checking for multilingual fields validity */
|
/* Checking for multilingual fields validity */
|
||||||
foreach ($rules['validateLang'] as $field_lang => $function)
|
if (isset($rules['validateLang']) && is_array($rules['validateLang']))
|
||||||
foreach ($languages as $language)
|
foreach ($rules['validateLang'] as $field_lang => $function)
|
||||||
if (($value = Tools::getValue($field_lang.'_'.$language['id_lang'])) !== false && !empty($value))
|
foreach ($languages as $language)
|
||||||
if (!Validate::$function($value))
|
if (($value = Tools::getValue($field_lang.'_'.$language['id_lang'])) !== false && !empty($value))
|
||||||
$this->errors[] = sprintf(
|
if (!Validate::$function($value))
|
||||||
Tools::displayError('The field %1$s (%2$s) is invalid.'),
|
$this->errors[] = sprintf(
|
||||||
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
Tools::displayError('The field %1$s (%2$s) is invalid.'),
|
||||||
$language['name']
|
call_user_func(array($class_name, 'displayFieldName'), $field_lang, $class_name),
|
||||||
);
|
$language['name']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -725,6 +725,7 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
$cache_active = 0;
|
$cache_active = 0;
|
||||||
else
|
else
|
||||||
$cache_active = 1;
|
$cache_active = 1;
|
||||||
|
|
||||||
if (!$caching_system = Tools::getValue('caching_system'))
|
if (!$caching_system = Tools::getValue('caching_system'))
|
||||||
$this->errors[] = Tools::displayError('Caching system is missing');
|
$this->errors[] = Tools::displayError('Caching system is missing');
|
||||||
else
|
else
|
||||||
@@ -733,6 +734,7 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
'define(\'_PS_CACHING_SYSTEM_\', \''.$caching_system.'\');',
|
'define(\'_PS_CACHING_SYSTEM_\', \''.$caching_system.'\');',
|
||||||
$new_settings
|
$new_settings
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($cache_active && $caching_system == 'CacheMemcache' && !extension_loaded('memcache'))
|
if ($cache_active && $caching_system == 'CacheMemcache' && !extension_loaded('memcache'))
|
||||||
$this->errors[] = Tools::displayError('To use Memcached, you must install the Memcache PECL extension on your server.').'
|
$this->errors[] = Tools::displayError('To use Memcached, you must install the Memcache PECL extension on your server.').'
|
||||||
<a href="http://www.php.net/manual/en/memcache.installation.php">http://www.php.net/manual/en/memcache.installation.php</a>';
|
<a href="http://www.php.net/manual/en/memcache.installation.php">http://www.php.net/manual/en/memcache.installation.php</a>';
|
||||||
@@ -778,8 +780,7 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
else
|
else
|
||||||
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
|
$this->errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||||
}
|
}
|
||||||
|
if ($redirecAdmin && (!isset($this->errors) || !count($this->errors)))
|
||||||
if ($redirecAdmin)
|
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
||||||
else
|
else
|
||||||
return parent::postProcess();
|
return parent::postProcess();
|
||||||
|
|||||||
Reference in new issue
Block a user