diff --git a/classes/Employee.php b/classes/Employee.php index c43ee37dc..1debb4eed 100644 --- a/classes/Employee.php +++ b/classes/Employee.php @@ -244,12 +244,15 @@ class EmployeeCore extends ObjectModel */ public function isLoggedBack() { - /* Employee is valid only if it can be load and if cookie password is the same as database one */ - return ($this->id - && Validate::isUnsignedId($this->id) - && Employee::checkPassword($this->id, $this->passwd) - && (!isset($this->remote_addr) || $this->remote_addr == ip2long(Tools::getRemoteAddr()) || !Configuration::get('PS_COOKIE_CHECKIP')) - ); + 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 */ + Cache::store('isLoggedBack'.$this->id, ( + $this->id && Validate::isUnsignedId($this->id) && Employee::checkPassword($this->id, $this->passwd) + && (!isset($this->remote_addr) || $this->remote_addr == ip2long(Tools::getRemoteAddr()) || !Configuration::get('PS_COOKIE_CHECKIP')) + )); + } + return Cache::retrieve('isLoggedBack'.$this->id); } /** diff --git a/classes/Tab.php b/classes/Tab.php index 5a0b211d8..94cb98de4 100644 --- a/classes/Tab.php +++ b/classes/Tab.php @@ -169,12 +169,18 @@ class TabCore extends ObjectModel */ public static function getCurrentParentId() { - if ($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' - SELECT `id_parent` - FROM `'._DB_PREFIX_.'tab` - WHERE LOWER(class_name) = \''.pSQL(Tools::strtolower(Tools::getValue('controller'))).'\'')) - return $result['id_parent']; - return -1; + $cache_id = 'getCurrentParentId_'.Tools::strtolower(Tools::getValue('controller')); + if (!Cache::isStored($cache_id)) + { + $value = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' + SELECT `id_parent` + FROM `'._DB_PREFIX_.'tab` + WHERE LOWER(class_name) = \''.pSQL(Tools::strtolower(Tools::getValue('controller'))).'\''); + if (!$value) + $value = -1; + Cache::store($cache_id, $value); + } + return Cache::retrieve($cache_id); } /**