stof / StofDoctrineExtensionsBundle

Integration bundle for DoctrineExtensions by l3pp4rd in Symfony
https://symfony.com/bundles/StofDoctrineExtensionsBundle/current/index.html
MIT License
1.89k stars 380 forks source link

Listeners not working #456

Closed loevgaard closed 1 year ago

loevgaard commented 1 year ago

Hi, Stof. Thanks for the bundle. I just wanted to report this. I haven't dug into it yet, but I can see you changed a lot regarding the subscribers/listeners in the 1.8 release.

When I upgraded to 1.8 (from 1.7.2), the listeners didn't work anymore. I am running a Sylius application, which uses your bundle under the hood.

I will come back later with more details hopefully.

loevgaard commented 1 year ago

Here's the debug:container for the timestampable in v1.7.2:

Information for Service "stof_doctrine_extensions.listener.timestampable"
=========================================================================

 The Timestampable listener handles the update of dates on creation and update.

 ---------------- -------------------------------------------------
  Option           Value
 ---------------- -------------------------------------------------
  Service ID       stof_doctrine_extensions.listener.timestampable
  Class            Gedmo\Timestampable\TimestampableListener
  Tags             doctrine.event_subscriber (connection: default)
  Calls            setAnnotationReader
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        no
  Autoconfigured   no
 ---------------- -------------------------------------------------

And here's for v1.8.0:

Information for Service "stof_doctrine_extensions.listener.timestampable"
=========================================================================

 The Timestampable listener handles the update of dates on creation and update.

 ---------------- -------------------------------------------------------------------------
  Option           Value
 ---------------- -------------------------------------------------------------------------
  Service ID       stof_doctrine_extensions.listener.timestampable
  Class            Gedmo\Timestampable\TimestampableListener
  Tags             doctrine.event_listener (connection: default, event: prePersist)
                   doctrine.event_listener (connection: default, event: onFlush)
                   doctrine.event_listener (connection: default, event: loadClassMetadata)
  Calls            setCacheItemPool, setAnnotationReader
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        no
  Autoconfigured   no
 ---------------- -------------------------------------------------------------------------

It certainly looks correct. Maybe it's an issue elsewhere. Will dig a bit more :)

stof commented 1 year ago

Are you using the timestampable behavior in a mapped superclass ?

If yes, this is a duplicate of https://github.com/stof/StofDoctrineExtensionsBundle/issues/455 which is actually an effect of a known bug in the library, not a bug in the bundle. The workaround for that bug (until it is fixed) is to make sure to configure a metadata cache for the extension that is at least as persistent than the metadata cache configured for the doctrine metadata (so either having no cache on both sides or having a persistent cache on both sides).

loevgaard commented 1 year ago

Are you using the timestampable behavior in a mapped superclass ?

Yes

I will close this issue and follow the other issue instead. Thanks for your quick response and have a great summer ☀️