-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
avoid trying to load nonexistent DoctrineTransportFactory class #1373
Conversation
This instead would also do: - if (! class_exists(\Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory::class)) {
+ if (! class_exists(\Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory::class, false)) { |
Build needs to be green. Please test if your second solution works in both scenarios, it's SA friendly |
I'm not sure this would, as it would not try to actually load the class and would rely on class loading order. |
I could only test if it's working in my scenario (to avoid the error), it does. |
OK, then I confirm this 2nd patch would break the logic when the package is found in vendor. |
Too bad. What about the failing SA then? |
Closing here, as this is a broken BC on Symfony side. Doctrine-bundle shouldn't have to update the code just so it keeps working with next minor symfony version. Please fix BC layer on Symfony side. |
Actually, just noticed code on symfony side didn't change since symfony 5.1, which is probably when we added class_exists, so it's our BC layer that was broken whole time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One solution which should be better is reversing the conditions. Default to new transport factory. If it doesn't exist, use legacy one.
Like this? - if (! class_exists(DoctrineTransportFactory::class)) {
- // If symfony/messenger < 5.1
- if (! class_exists(\Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory::class)) {
- // Dont add the tag
- return;
- }
-
- $transportFactoryDefinition->setClass(\Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory::class);
- }
-
- $transportFactoryDefinition->addTag('messenger.transport_factory');
+ if (class_exists(DoctrineTransportFactory::class)) {
+ $transportFactoryDefinition->addTag('messenger.transport_factory');
+ } elseif (class_exists(\Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory::class, false)) {
+ // symfony/messenger >= 5.1
+ $transportFactoryDefinition->setClass(\Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory::class);
+ $transportFactoryDefinition->addTag('messenger.transport_factory');
+ } |
/ping |
yes, but without false flag |
Without it, I'd get the initial error again. |
I'm back to my first response: It's an issue on Symfony side. I've created symfony/symfony#42303. As for what you can do, you can call |
Calling
although I'm not actively using the messenger and cannot see a way to get rid of that deprecation notice. |
see referenced issue. stop using symfony/symfony |
This fixes symfony/symfony#41727.