Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Running Sessions (v2.7) with EventManager (v3) #12

Open
weierophinney opened this issue Dec 31, 2019 · 2 comments
Open

Error Running Sessions (v2.7) with EventManager (v3) #12

weierophinney opened this issue Dec 31, 2019 · 2 comments

Comments

@weierophinney
Copy link
Member

In ValidatorChain.php:

use Zend\EventManager\GlobalEventManager;`

// ...

if (class_exists(GlobalEventManager::class)) {
    class_alias(Validator\AbstractValidatorChainEM2::class, AbstractValidatorChain::class);
} else {
    class_alias(Validator\AbstractValidatorChainEM3::class, AbstractValidatorChain::class);
}

However GlobalEventManager is not available since version 2.6 of the EventManager and therefor causes problems with version 3.

PHP 5.6 running on WAMP Server.

I don't know if this happens all the time, guess it will... What I've done is NOT loading the module and initialize the session manager by hand:

$sessionConfig = new SessionConfig();
$session = new SessionManager($sessionConfig);
$session->start();

It will cause the error due to the missing GlobalEventManager class and if you bring the class from version 2.6 then the next reported error comes allong due to the missing callabledeclaration in AbstractValidatorChainEM2::attach method.


Originally posted by @JPG-Consulting at zendframework/zend-session#62

@weierophinney
Copy link
Member Author

However GlobalEventManager is not available since version 2.6 of the EventManager and therefor causes problems with version 3.

Could you provide an error message? (or put another way: how do you know it isn't working?)

This aliasing "trick" works and is tested in the CI system against both EMv3 and EMv3, The Validator Chain has separate implementations for EMv2 and EMv3 (AbstractValidatorChainEM2 and AbstractValidatorChainEM3, respectively) and the FQCN Zend\Session\AbstractValidatorChain is aliased to the appropriate one at runtime based on which version of EM you have installed. When using EMv3 the class_exists call will return false (since the class doesn't exist) and so the else block will be executed, aliasing the AbstractValidatorChain class name to the EMv3 implementation (AbstractValidatorChainEM3).


Originally posted by @adamlundrigan at zendframework/zend-session#62 (comment)

@LukaszSawicki
Copy link

LukaszSawicki commented Feb 25, 2020

When using EMv3 the class_exists call will return false (since the class doesn't exist) and so the else block will be executed, aliasing the AbstractValidatorChain class name to the EMv3 implementation (AbstractValidatorChainEM3).

Hi, the class_exists function is returning 'false' when class doesn't exists, but it tries to autoload it anyway. In php documentation you can see that function class_exists has second parametr, which tells if it should to autoload class or not (https://www.php.net/manual/en/function.class-exists.php). Because the parameter is set to 'true' by default, it throws error:
Reason: include_once(Laminas/EventManager/GlobalEventManager.php): failed to open stream: No such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants