magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Interception on customer auth not working using php 5.5.19

Open toonvd opened this issue 11 years ago • 14 comments

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 avatar Jan 22 '15 08:01 toonvd

@toonvd, could you provide more details about this issue and provide class and method which you are going to customize?

vpelipenko avatar Jan 22 '15 10:01 vpelipenko

@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.

toonvd avatar Jan 22 '15 15:01 toonvd

Have you cleared folder var/cache after you added your plugin?

Sanuch avatar Jan 22 '15 15:01 Sanuch

@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 avatar Jan 22 '15 15:01 toonvd

@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

Sanuch avatar Jan 24 '15 09:01 Sanuch

@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.

vpelipenko avatar Jan 26 '15 17:01 vpelipenko

Allright, will do it this afternoon.

toonvd avatar Jan 27 '15 08:01 toonvd

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 ;-)

toonvd avatar Jan 31 '15 10:01 toonvd

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

Sanuch avatar Feb 01 '15 10:02 Sanuch

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 avatar Feb 01 '15 12:02 toonvd

@toonvd, did you have a chance to check it again?

vpelipenko avatar Feb 09 '15 15:02 vpelipenko

@vpelipenko yes, it does not work, but I am trying to find the problem so I can give you a reproducable case.

toonvd avatar Feb 09 '15 15:02 toonvd

@toonvd, we are wating for results of your investigation. We've also created internal ticket MAGETWO-33842 to check this issue again.

vpelipenko avatar Feb 09 '15 16:02 vpelipenko

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

toonvd avatar Feb 20 '15 19:02 toonvd