-
-
Notifications
You must be signed in to change notification settings - Fork 448
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
Doctrine listeners not referencing the right services #1166
Comments
I wasn't able to reproduce this with <?php
namespace App\EventSubscriber;
use Doctrine\Common\EventArgs;
use Doctrine\Common\EventManager;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Events;
use Psr\Container\ContainerInterface;
class Issue36783Subscriber implements EventSubscriber
{
/**
* @var ContainerInterface
*/
private $container;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public function postLoad(EventArgs $eventArgs)
{
var_dump($this->container->get(self::class) === $this);
}
public function getSubscribedEvents()
{
return [Events::postLoad];
}
} Please post failing test case, or reproducer according instructions I posted in linked issue. |
@ostrolucky Here the demo : symfony/symfony#36783 (comment) |
Codeception symfony module reboots kernel by default in https://github.com/Codeception/module-symfony/blob/e60d4266644099ba2cccad9ae22cef3ceb6c0039/src/Codeception/Module/Symfony.php#L214 so you probably want to use |
Actually using that option does not help, however this is still an issue of Symfony module, as commenting out rebootKernel call from |
Not using Doctrine2 module make it works (see Codeception/Codeception#3497) It is a solution for us as we only use Db module |
Hi,
Environement test
Symfony 4.4.8
Doctrine 2.0.8
Description
Doctrine subscribers (or listeners) services are not the same if fetched from container or fetched by doctrine events. If i dump the spl_object_id of a doctrine subscriber fetched from the container and the spl_object_id of the same doctrine subscriber but fired by a doctrine event (like onFlush), this is not the same id.
It implies that all injected services are also not the right ones (are they duplicated ?). Messenger transports are also impacted : transport is
duplicated
when coming from doctrine eventMaybe the test container is guilty ?
Symfony issue : symfony/symfony#36783
The text was updated successfully, but these errors were encountered: