doctrine / DoctrineORMModule

Doctrine ORM Module for Laminas
https://www.doctrine-project.org/projects/doctrine-orm-module.html
MIT License
439 stars 229 forks source link

Fatal Error in Module class at Version 1.1.8 #567

Closed DennisDobslaf closed 6 years ago

DennisDobslaf commented 6 years ago

https://github.com/doctrine/DoctrineORMModule/blob/a205cc69e35633ced3723629dc54f7edea677841/src/DoctrineORMModule/Module.php#L56

In my case this leads to a fatal error. Message: "Fatal error: Uncaught Error: Call to undefined method Zend\ModuleManager\ModuleManager::getParam() in \vendor\doctrine\doctrine-orm-module\src\DoctrineORMModule\Module.php on line 56"

It seems, that $event->getTarget() is instanceof Zend\ModuleManager\ModuleManager, which has no getParam() method!

TomHAnderson commented 6 years ago

Since releaseing 1.1.8 I've had a report that this line does work and your report that this line does not work.

Here's the line in question: https://github.com/doctrine/DoctrineORMModule/blob/release/1.1.8/src/DoctrineORMModule/Module.php#L56

This is triggered here: https://github.com/zendframework/ZendDeveloperTools/blob/master/src/Module.php#L63

In the triggering the $event is passed a Zend\ModuleManager\ModuleEvent for 1.1.8 and 2.1.5 which both address this listener.

Please post your composer show result.

thomasvargiu commented 6 years ago

I think could be a issue between different zend-modulemanager releases.

Btw we know that it worked in version 1.1.5. Here the difference.

Now the event used for retrieving the ServiceManager is not the same as in release 1.1.5. We should change it like this:

$manager
    ->getEventManager()
    ->attach(
        ProfilerEvent::EVENT_PROFILER_INIT,
        function () use ($manager) {
            $container = $manager->getEvent()->getTarget()->getParam('ServiceManager');
            $container->get('doctrine.sql_logger_collector.orm_default');
        }
    );

@DennisDobslaf we still need your composer show result to understand which module causes the issue. @TomHAnderson (almost) every package used in use statement I think should be in the composer.json as requirement, including zend-eventmanager, zend-modulemanager, etc...

DennisDobslaf commented 6 years ago

off course. here is the composer show result (I skipped private repo names!)

thomasvargiu commented 6 years ago

The problem is a BC break with zend-eventmanager 2.7.x and 3.x.

Using the trigger() method, in version 3.x a new event is created, and the target is the event. In version 2.7 the event is the original event, where the target is the Zend\ModuleManager\ModuleManager.

I think it's a bug in ZendDeveloperTools that it's not really compatible with both versions.

Like I suggested above, those changes should fix the problem.