// Small backend optimization

This commit is contained in:
Damien Metzger committed 2013-07-23 09:50:26 +02:00
1 parent 4b6642d76c
commit 91c5d184b6
2 files changed
+17 -8

No files matched your search

+7 -4
View File
@@ -243,13 +243,16 @@ class EmployeeCore extends ObjectModel
* @return boolean employee validity * @return boolean employee validity
*/ */
public function isLoggedBack() public function isLoggedBack()
{
if (!Cache::isStored('isLoggedBack'.$this->id))
{ {
/* Employee is valid only if it can be load and if cookie password is the same as database one */ /* Employee is valid only if it can be load and if cookie password is the same as database one */
return ($this->id Cache::store('isLoggedBack'.$this->id, (
&& Validate::isUnsignedId($this->id) $this->id && Validate::isUnsignedId($this->id) && Employee::checkPassword($this->id, $this->passwd)
&& Employee::checkPassword($this->id, $this->passwd)
&& (!isset($this->remote_addr) || $this->remote_addr == ip2long(Tools::getRemoteAddr()) || !Configuration::get('PS_COOKIE_CHECKIP')) && (!isset($this->remote_addr) || $this->remote_addr == ip2long(Tools::getRemoteAddr()) || !Configuration::get('PS_COOKIE_CHECKIP'))
); ));
}
return Cache::retrieve('isLoggedBack'.$this->id);
} }
/** /**
+10 -4
View File
@@ -169,12 +169,18 @@ class TabCore extends ObjectModel
*/ */
public static function getCurrentParentId() public static function getCurrentParentId()
{ {
if ($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' $cache_id = 'getCurrentParentId_'.Tools::strtolower(Tools::getValue('controller'));
if (!Cache::isStored($cache_id))
{
$value = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_parent` SELECT `id_parent`
FROM `'._DB_PREFIX_.'tab` FROM `'._DB_PREFIX_.'tab`
WHERE LOWER(class_name) = \''.pSQL(Tools::strtolower(Tools::getValue('controller'))).'\'')) WHERE LOWER(class_name) = \''.pSQL(Tools::strtolower(Tools::getValue('controller'))).'\'');
return $result['id_parent']; if (!$value)
return -1; $value = -1;
Cache::store($cache_id, $value);
}
return Cache::retrieve($cache_id);
} }
/** /**