Feature request from jacquesbh, posted on GitHub Jul 23, 2016
I'm playing with performances issues.
One of them (too much to write an issue for each) is that the Customer is loaded on each page, event if the customer isn't logged in!
There is no test about the possibility of having a customer's ID equal to null
in the source code.
Preconditions
- Magento EE 2.0.2 (but doesn't matter, it is in CE too…)
- Nginx / PHP5-fpm
Steps to reproduce
The problem is there: https://github.com/magento/magento2/blob/2d368d0134597257ef5697a4bcbb7f69f2aebed8/app/code/Magento/C...
If you want to test this just add this before the line 288 on the file above:
syslog(7, 'Value of the customer\'s ID is ' . var_export($this->getCustomerId(), true));
Which results in:
/**
* Retrieve customer model object
*
* @return Customer
* use getCustomerId() instead
*/
public function getCustomer()
{
if ($this->_customerModel === null) {
syslog(7, 'Value of the customer\'s ID is ' . var_export($this->getCustomerId(), true));
$this->_customerModel = $this->_customerFactory->create()->load($this->getCustomerId());
}
return $this->_customerModel;
}
Expected result
- If the customer is logged in: look your syslog and you should get something like
Jul 23 16:38:16 magento2ee: Value of the customer's ID is 1
- If the customer isn't logged in: you shouldn't get any log because a customer with the ID
null
shouldn't be loaded.
Actual result
- We always get a log… and specially a
Value of the customer's ID is NULL
if the customer isn't logged in.