Closed PierrickMartos closed 3 years ago
This might very well be relevant https://github.com/doctrine/DoctrineBundle/pull/1196. Can you check if reverting those changes fixes your issue?
Hi @ostrolucky , i confirm, by reverting the two commits it works.
Here is the repository with the revert commits: https://github.com/Software-For-Asset-Management/DoctrineBundle/tree/master
Reproducer would be more useful. I'm unable to reproduce the issue. Tried with 2.2.0, under prod, with prePersist, with @ORM\MappedSuperclass
, without @ORM\EntityListeners
. Listener is triggered every time.
Have the same issue with 2.2.0, with postPersist event.
For reproduce just needed run cache warm up:
bin/console cache:warmup --env=prod --no-debug
Indeed, I've reproduced this now
@zubov-ruslan how exactly did you produce this diff in the screenshot? So in one default_metadata.php
file the entitylisteners
are present and in the other one not?
So far I can reproduce the missing case. But I cannot get it to show entitylisteners
with 2.2.0 on my project
@dmaicher it happens when you run bin/console cache:warmup --env=prod --no-debug
for the second time
We decided to rollback the change which caused this issue. We released 2.2.1 which should fix your issue.
@dmaicher Did you be able to reproduce?
@zubov-ruslan I can't reproduce even after run cache warmup multiple times. Do you do something between two calls of cache warmup? What is your metadata_cache_driver
configuration? Do you use one or several entity managers?
Crucial part for reproducing is not defining @ORM\EntityListeners
, listener needs to be solely defined via service definition only.
@ostrolucky I've changed the listener definition from annotations to services, but everything still works. Just difference is a new service listener appears in the container.
bug is only in prod mode, with warmed up cache, since that's where feature works
I've reproduced this. When entity listeners declared using services config they are added to metadata using event manager in AttachEntityListenersListener
. When we warming up the php array cache we creating a clear ClassMetadataFactory
with no event listeners. Using ClassMetadataFactory
from container should fix this, I'll try to create a fix.
Since AttachEntityListenersListener
attach listener only once the best solution I see is to set the highest priority to DoctrineMetadataCacheWarmer
.
@PierrickMartos @zubov-ruslan Could you please check this solution, please checkout to 2.2.0 and change this line ->addTag('kernel.cache_warmer');
to ->addTag('kernel.cache_warmer', ['priority' => 1000]);
?
I would really suggest to give us a feedback and try the suggested changes if you don't want us to break your application again in next release.
I try to find a moment to reproduce it in coming days
Hi @ossinkine i've made some tests, i confirm that it doesnt work when changing ->addTag('kernel.cache_warmer');
to ->addTag('kernel.cache_warmer', ['priority' => 1000]);
Hello,
Since the release of
doctrine-bundle:2.2.0
, we are facing a strange issue with our EntityListeners not called only when symfony run under prod env. Note, It works normally ondev
andtest
env.To give you more context, our EntityListener is registered on a MappedSuperClasss and not directly on the final Entity class. But we never had an issue with this before the 2.2.0 release.
Here is how we register our EntityListener (the service is registered inside a vendor managed by us):
Here is the
DealFlowListener
:The mappedsuperclass,
DealFlow
:And the
DealFlow
final entity:Also, when i run
bin/console --env=prod debug:container DealFlowListener
on production, the service appears and it's registered into the container :For now we have fix our
composer.json
to doctrine-bundle 2.1.2 and it works.Our environment :
Our
composer.json
: