ZF-Commons / ZfcUser

A generic user registration and authentication module for ZF2. Supports Zend\Db and Doctrine2. (Formerly EdpUser)
BSD 3-Clause "New" or "Revised" License
497 stars 343 forks source link

ZF3 compatibility (and general) improvements #656

Closed zluiten closed 7 years ago

zluiten commented 7 years ago

642

phgeek commented 7 years ago

Hi @netiul I'm using your PR and got an error when login in:

File:
vendor/zf-commons/zfc-user/src/ZfcUser/Authentication/Adapter/AdapterChain.php:90
Message:
Call to a member function getListeners() on null

By commenting the resetAdapters function content it works. Any idea on what's wrong?

PS: Using along with ZfcUserDoctrineORM.

hilyafadhilah commented 7 years ago

@phgeek @netiul I found out that AdapterChain class calls getEventManager() that lazy-loads an EventManager instance if none is registered. This lazy-loaded instance have $sharedEventManager defaults to null. This is the line in resetAdapters() that made the error.

$listeners = $this->getEventManager()->getSharedManager()->getListeners(['authenticate'], 'authenticate');

Basically, getSharedManager() returned null because no $sharedEventManager was set. And so, the call for getListeners() trigerred an error. The fix would be to check first if it's null, right?

Also, I noticed that ZfcUserDoctrineORM should also be changed to be compatible with the PR. ZfcUserDoctrineORM/Mapper/User::insert() and ZfcUserDoctrineORM/Mapper/User::update() methods must use type hint now.

Other than that, this PR is really cool. 👍

Danielss89 commented 7 years ago

Thank you, your changes have been introduced in 3.x!

jroedel commented 7 years ago

Great work Daniel! Thanks a lot for taking on this huge project. Users: We've been waiting a long time for this, let's work to upgrade to 3.0 to work out any bugs quickly. I'm sure I'm not the only one who's still on ZF2, waiting for ZfcUser to upgrade.