KnpLabs / DoctrineBehaviors

Doctrine2 behavior traits that help handling Blameable, Loggable, Sluggable, SoftDeletable, Uuidable, Timestampable, Translatable, Tree behavior
http://knplabs.com
MIT License
914 stars 294 forks source link

Incommpatible with symfony 5.2-rc #608

Closed mmarton closed 3 years ago

mmarton commented 3 years ago

Hi!

if the bundle is installed symfony's boot process got into an infinite loop and dies with memory out.

UPDATE: works with 5.2.0-RC2. I'll wait the final release and close it after.

TomasVotruba commented 3 years ago

Hi,

thanks for reporting. Having Symfony 5.2 in CI would help to keep eyes on it.

Any ideas where that gets stuck?

mmarton commented 3 years ago

I'm not an expert of the DI container build process, but seemd like the getdoctrineentitymanager and get***subscriber called each other. I'll check out tomorrow

TomasVotruba commented 3 years ago

I see. That might a be a good lead.

Thank you for looking into it

mmarton commented 3 years ago

It seems like the problem it with the Blameable and SluggableSubscribers that take EntityManager az a constructor argument You can get the entitiymanager from the events.

public function prePersist(LifecycleEventArgs $lifecycleEventArgs): void
{
    $em = $lifecycleEventArgs->getEntityManager();
...
}
TomasVotruba commented 3 years ago

Thanks for finding the spot.

How could we fix this place to avoid circular loops?

mmarton commented 3 years ago

https://github.com/symfony/symfony/issues/39015

This looks similar, so maybe nothing, maybe what I suggested in the earlier comment

diabelb commented 3 years ago

You can test this pull request: https://github.com/KnpLabs/DoctrineBehaviors/pull/609 composer require diabelb/doctrine-behaviors

Grandnainconnu commented 3 years ago

You can test this pull request:

609

composer require diabelb/doctrine-behaviors

Works perfectly for me in 5.2 with your patch, had infinite loop before on cache:clear

mmarton commented 3 years ago

Tested with 5.2.0-RC2 and the problen mo longer exists. (still not nice to inject entitymanager to a subscriber, but thats another story)

mmarton commented 3 years ago

Works with the 5.2.0 release

TomasVotruba commented 3 years ago

Thank you