Interception on customer auth not working using php 5.5.19
Hi,
On PHP 5.5.19 my plugin on customer authentication does not work, when I upgrade to 5.5.25 or php 5.4 it does I have the feeling this is not a bug in interception but a Bug in de customer Module like Anton Krill said. This might be a bug worth looking at.
@toonvd, could you provide more details about this issue and provide class and method which you are going to customize?
@vpelipenko i was trying to use a plugin on authentication, works in all php versions but this one. Below is the code:
di.xml
<!-- plugin on customer login -->
<type name="Magento\Customer\Model\AccountManagement">
<plugin name="customernumber" type="Phpro\Customernumber\Model\Plugin\AccountManagement" sortOrder="10" />
</type>
Accountmanagement code
/**
* @param $subject
* @param $result
* @return mixed
*/
public function afterAuthenticate($subject, $result)
{
try {
$this->_addClientNumberToCustomerIfNotExists($result);
} catch (Exception $e) {
$this->helper->error($e->getMessage());
}
return $result;
}
/**
* @param $customerSession
* @return bool
*/
protected function _addClientNumberToCustomerIfNotExists($customerSession)
{
$customerModel = $this->customerModel;
$customer = $customerModel->load($customerSession->getId());
if (!$customer->hasCustomerNumber()) {
//this should be a webservice call
$customer->setCustomerNumber('testCustomerId1234');
$customer->save();
}
}
I am getting no error in Apache or page or the log files in var/log with developer mode enabled, it simply does not work.
Have you cleared folder var/cache after you added your plugin?
@Sanuch yes, furthermore, basic questions will not apply in this case since it worked on other php versions on the same codebase, I should mention that this was before i joined centercode and did some betatesting. Been trying for atleast an hour back then... :disappointed:
@toonvd , I'm working whith this version of php and have not problem whith interception. Could you provide full code of your plugin for AccountManagement
@toonvd, we've checked the code you provided and it works on PHP 5.5.19. Probably, it is something with file/class naming. It will be good if you share all your changes with us (for example, in separate branch in you forked repository). Thanks.
Allright, will do it this afternoon.
Hi,
The extension is on https://github.com/toonvd/magento2/tree/develop/app/code/Phpro/Customernumber.
Just to make sure there are no remarks on this. I stripped the settings file but i did fill in my extension name :). Sorry for the delay, busy days ;-)
HI @toonvd
I checked your plugin on my local environment and it works. I added not exists function to AccountManagement::afterAuthenticate and tried login with exists user and I received fatal error Call to undefined function ... in AccountManagement.php on line 40
I use XAMPP with PHP 5.5.19
Hi, could be that the bug was fixed meanwhile... i had it in december... I'll recheck with the current Github version in my Vagrant box and close when this works, thanks!
@toonvd, did you have a chance to check it again?
@vpelipenko yes, it does not work, but I am trying to find the problem so I can give you a reproducable case.
@toonvd, we are wating for results of your investigation. We've also created internal ticket MAGETWO-33842 to check this issue again.
Hi, since I migrated to another host w/ same php version I didnt manage to reproduce this anymore. Might have been a bad setup... If you cannot reproduce either, it might be better to close