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
Fix BC break with DoctrineType::reset() for all Symfony versions #970
Conversation
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.
See feedback on the conditional.
632cbb6
to
125602a
Compare
@alcaeus Fixed, please check. |
@@ -343,6 +344,11 @@ protected function ormLoad(array $config, ContainerBuilder $container) | |||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); | |||
$loader->load('orm.xml'); | |||
|
|||
// This check can be removed when support for Symfony < 4.2 is dropped | |||
if (!method_exists(AbstractController::class, 'addLink')) { |
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.
This checks the version of the FrameworkBundle which doesn't have to be the same as the one of the DoctrineBridge (which provides the type).
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.
So we also need to check whether the type implements the ResetInterface?
125602a
to
ba4ce9c
Compare
ba4ce9c
to
400be2e
Compare
// This check can be removed when support for Symfony < 4.2 is dropped | ||
if (! interface_exists(ResetInterface::class) | ||
|| ! is_a(DoctrineType::class, ResetInterface::class) | ||
|| ! $container->getDefinition('form.type.entity')->hasTag('kernel.reset')) { |
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.
If this works reliably (I’m not sure because I don’t know when autoconfig is applied, ping @nicolas-grekas) I don’t believe we need the other checks at all 🤔
0b636c8
to
5e66303
Compare
@alcaeus It seems to be the most reliable solution according to above comments, because method |
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.
Sorry, more feedback needed from @doctrine/team-symfony-integration.
That would be a BC break which would only be possible in a major release: this bundle would not install such a version without modifications. |
5e66303
to
d4d1858
Compare
@alcaeus So we return to the first solution, which was correct, because it:
|
The safe choice:
Note that checking for the The "yeah, this won't break choice":
As I said - I couldn't find any side effects from having two |
d4d1858
to
2d71bd5
Compare
@alcaeus Done, please check. |
2d71bd5
to
4d68215
Compare
@alcaeus @xabbuh Hi guys, I have tested this fix with Symfony 4.2 and 4.3 and have just realized that even in these recent versions of Symfony Actually this So I modified code to explicitly add |
The check for the existence of the method is still necessary, isn't it? Otherwise the kernel might call try to call the method because of the tag while it actually doesn't exist. |
4d68215
to
112443f
Compare
@xabbuh Well, actually this check is not so critical, because removing By the way, we returned to the implementation I already did 16 days ago: #970 (comment) |
Ah sorry, that's my mistake. I thought the method wasn't present in Symfony 3.4. |
So if we don't need the check, can't we just add the tag in the XML config file where we define the service config? |
No, unfortunately we cannot hardcode this tag, because this bundle doesn't have I have already tried to do this unconditionally, and unit tests were failed. |
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.
Sorry for all the back and forth here - I guess we were all blind. However, we can just check if symfony/form
is installed, everything else is (as you already mentioned) unnecessary. I'll tag a new release once the changes below have been made.
Fixes BC break with mistakenly removed `kernel.reset` tag from `form.type.entity` service, because `DoctrineType` implements `ResetInterface`, but this service is not autoconfigured, so the `kernel.reset` tag won't be added automatically. This BC break was introduced in version 1.11.0 in commit 6b25ea4
112443f
to
043b425
Compare
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.
Thanks @javer, and sorry for taking a few laps around the block to realise what's going on here!
Fixes BC break with mistakenly removed
kernel.reset
tag fromform.type.entity
service, becauseDoctrineType
implementsResetInterface
only in Symfony 4.2+, therefore all previous versions starting from 3.4 are affected.This BC break was introduced in version 1.11.0 in commit 6b25ea4