// Improve performance

This commit is contained in:
rGaillard
2012-03-12 14:50:56 +00:00
parent 0a3ed0b9eb
commit 3d0ccb91eb
4 changed files with 19 additions and 11 deletions
+8 -6
View File
@@ -293,12 +293,14 @@ class AddressCore extends ObjectModel
*/
public static function addressExists($id_address)
{
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT `id_address`
FROM '._DB_PREFIX_.'address a
WHERE a.`id_address` = '.(int)$id_address);
return isset($row['id_address']);
$key = 'address_exists_'.(int)$id_address;
if (!Cache::isStored($key))
Cache::store(
$key, Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT `id_address`
FROM '._DB_PREFIX_.'address a
WHERE a.`id_address` = '.(int)$id_address));
return Cache::retrieve($key);
}
public static function getFirstCustomerAddressId($id_customer, $active = true)
+2 -3
View File
@@ -368,10 +368,9 @@ class HookCore extends ObjectModel
// Call hook method
if ($hook_callable)
$display = call_user_func(array($moduleInstance, 'hook'.$hook_name), $hookArgs);
$display = $moduleInstance->{'hook'.$hook_name}($hookArgs);
else if ($hook_retro_callable)
$display = call_user_func(array($moduleInstance, 'hook'.$retro_hook_name), $hookArgs);
$display = $moduleInstance->{'hook'.$retro_hook_name}($hookArgs);
// Live edit
if ($array['live_edit'] && ((Tools::isSubmit('live_edit') && Tools::getValue('ad') && (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))))
{
+3 -1
View File
@@ -3448,7 +3448,9 @@ class ProductCore extends ObjectModel
{
if (!$row['id_product'])
return false;
$context = Context::getContext();
if ($context == null)
$context = Context::getContext();
// Product::getDefaultAttribute is only called if id_product_attribute is missing from the SQL query at the origin of it:
// consider adding it in order to avoid unnecessary queries
+6 -1
View File
@@ -115,6 +115,7 @@ class TranslateCore
{
global $_MODULES, $_MODULE, $_LANGADM;
static $lang_cache = array();
static $translations_merged = array();
if ($module instanceof Module)
{
@@ -134,7 +135,11 @@ class TranslateCore
$file = $local_path.'/'.Context::getContext()->language->iso_code.'.php';
if (Tools::file_exists_cache($file) && include_once($file))
$_MODULES = !empty($_MODULES) ? array_merge($_MODULES, $_MODULE) : $_MODULE;
{
if (!isset($translations_merged[md5($file)]))
$_MODULES = !empty($_MODULES) ? array_merge($_MODULES, $_MODULE) : $_MODULE;
$translations_merged[md5($file)] = true;
}
$string = str_replace('\'', '\\\'', $string);