Skip to content
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

[DoctrineBridge] Integrate doctrine/deprecations #41408

Closed
wants to merge 1 commit into from

Conversation

ostrolucky
Copy link
Contributor

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets doctrine/DoctrineBundle#1300
License MIT
Doc PR -

This automatically enables deprecations triggered via doctrine/deprecations in standard symfony deprecations mode. Currently, symfony error-handler and phpunit-bridge are not aware of such deprecations with stock configuration of doctrine/deprecations. That might be a bug from user's POV. This patch fixes that.

We don't want this in a bundle, because all bundles using doctrine-bridge shouldn't have to reimplement this separately.

@stof
Copy link
Member

stof commented May 26, 2021

This won't automatically solve it for all doctrine libraries. symfony/doctrine-bridge is providing integrations with doctrine/dbal and doctrine/persistence. A projects using doctrine/annotations might not be using that bridge for instance.

@ostrolucky
Copy link
Contributor Author

That's not the intention and wouldn't be wanted by users either. Intention is provide integration for bundles. Bundles shouldn't have to integrate this separately by copy & pasting it to each bundle, that's what we have bridge here for.

@stof
Copy link
Member

stof commented May 26, 2021

@ostrolucky but FrameworkBundle should not have to depend on symfony/doctrine-bridge just to configure that deprecation layer for its usage of doctrine/annotations, while bring all dependencies of the doctrine-bridge.

the issue is that we have one package named symfony/doctrine-bridge, but "doctrine" does not refer to a single integration target. there are lots of independent Doctrine packages. Note that this historical mistake of considering that the whole doctrine is a single thing as far as the bridge is concerned is something we are moving away for new features. The DBAL transport for messenger is not in symfony/doctrine-bridge but in doctrine-messenger (even though this one still makes the mistake of mixing the DBAL integration and the persistence integration)

Copy link
Contributor

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm against this change. The bridge is a legacy thing that should be moved to the doctrine namespace. In the end, it's our own bundle architecture we're abstracting here, which has no place in the Symfony repository.

In my opinion, it's up to end users to think about how they want to collect various deprecations. While Symfony itself uses trigger_deprecation, other libraries may have their own way of announcing these, and only the user knows what to do with the various deprecations.

That said, since each bundle has to make a decision on how to handle this (ODM is not using doctrine/deprecations and most likely won't ever) we shouldn't put this change in the bridge. Users of the DoctrineBundle will have this configured automatically. Users of Symfony that use annotations or any other library explicitly should configure the Doctrine Deprecations library themselves (e.g. if they're only using the doctrine/annotations package). If they use doctrine packages implicitly, they don't need to do anything since they won't be interested in the deprecations anyways. That covers it from a Symfony perspective, so there's no need for this change.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented May 26, 2021

Thanks for opening the PR so that we can have this conversation.

If I understand @stof's objections, a way to account for them would be to move this to FrameworkBundle.

BUT now that I read @alcaeus' reasoning, I think we might better decide to NOT do anything, neither in this repository, NOR in DoctrineBundle.

The doctrine/deprecation library defaults to being a no-op, and explains that if ppl want to have to have some reports about the deprecations, they should enable it. This is just fine!

@nicolas-grekas
Copy link
Member

nicolas-grekas commented May 26, 2021

if ppl want to have to have some reports about the deprecations, they should enable it

BTW, IF we're looking for a place to configure the global state managed by the lib, the only place where this would make sense is in the runtime component to me.

@stof
Copy link
Member

stof commented May 26, 2021

@nicolas-grekas either that, or in a recipe for the doctrine/deprecations package if we can find a way to hook it

@ostrolucky
Copy link
Contributor Author

but FrameworkBundle should not have to depend on symfony/doctrine-bridge just to configure that deprecation layer for its usage of doctrine/annotations, while bring all dependencies of the doctrine-bridge.

It doesn't have to. It's one line of code, you don't need to require bridge for that. I've put it in bridge because bridge is what you use if you need doctrine-bundle or odm bundle, which is most symfony framework users. And that's also when you use most doctrine packages. But this change might not make sense for users if you don't use those bundles. I for one wouldn't enable this mode if I use doctrine/deprecations as the only doctrine package.

Users of the DoctrineBundle will have this configured automatically.

They won't. I have created this PR in order for this to be done. If it's rejected in name of coupling, same reason will be used for not integrating it in doctrine-bundle. You know, whole "why should frameworkbundle require doctrine-bundle if you use doctrine/annotations only" thing.

The bridge is a legacy thing that should be moved to the doctrine namespace.

I've never seen this view point acknowledged by Symfony maintainers. If that's right, issue should be created here so getting rid of doctrine-bridge to-do is visible and acknowledged.

In my opinion, it's up to end users

Yes it is, my patch is just providing default which makes sense in context of doctrine bundles. User can always change it in their own bootstrap code. Whole consistency is paramount thing. Symfony framework users expect deprecations are visible in profiler out of the box.

Btw may I remind I was repeatedly asked to provide this integration in doctrine-bundle? And now suddenly it's too coupled even if it was in doctrine-bridge, which is more generic than doctrine-bundle. I'm fine with wherever you put it, if somewhere, but stop asking doctrine-bundle to do this. And next time let's have this conversation before creating a patch too.

@stof
Copy link
Member

stof commented May 26, 2021

Btw may I remind I was repeatedly asked to provide this integration in doctrine-bundle? And now suddenly it's too coupled even if it was in doctrine-bridge, which is more generic than doctrine-bundle.

I'm not saying that this is too coupled. I'm saying that putting that into doctrine-bridge is not generic enough, because this bridge only covers a subset of doctrine libraries that will use doctrine/deprecations to trigger their deprecations (and so would not solve the issue if the project is using one of the no-covered libraries).

The bridge is a legacy thing that should be moved to the doctrine namespace. In the end, it's our own bundle architecture we're abstracting here, which has no place in the Symfony repository.

Well, the doctrine-bridge is not entirely legacy. Parts of it are (the abstract DI extension sharing some logic between DoctrineBundle and DoctrineMongodbODMBundle definitely is). Other parts (a form type integrating with doctrine/persistence for instance) totally belong to a symfony bridge. The cleaner architecture for those other bridges is that we should not have one doctrine-bridge bridging symfony/* and doctrine/* but separate bridges for the various components (be them on the symfony or doctrine side), as we do for modern Symfony components like mailer or messenger that have dedicated bridge packages.

@ostrolucky
Copy link
Contributor Author

If doctrine-bridge isn't generic enough (
and you might very well be correct in that), doctrine-bundle definitely isn't generic enough as well. So that's what am I saying. Don't expect this bootstrapping code to land there for same reason it won't land in doctrine-bridge.

@stof
Copy link
Member

stof commented May 26, 2021

BUT now that I read @alcaeus' reasoning, I think we might better decide to NOT do anything, neither in this repository, NOR in DoctrineBundle.

Users using doctrine/annotations generally rely on FrameworkBundle to provide them a configured reader. So I would say that they would also expect FrameworkBundle to configure the way the annotation reader reports deprecations.

@wouterj
Copy link
Member

wouterj commented May 26, 2021

If all users expect Doctrine packages to show deprecations, why doesn't doctrine/deprecations show deprecations by default?

@stof
Copy link
Member

stof commented May 26, 2021

@wouterj all Symfony users expect it to be reported in the Symfony way (or at least that's our assumption). that's still not the same than "all users"

@nicolas-grekas
Copy link
Member

My preference would be for doctrine/deprecation to embed a Symfony bundle and have it enabling deprecations for dev+test by default in a recipe.

@nicolas-grekas
Copy link
Member

Thank you all for the discussion, I think we've settled on this topic.
doctrine/deprecation should ideally embed a Symfony bundle.

@mpdude
Copy link
Contributor

mpdude commented May 26, 2023

Current situation: Doctrine ORM users have to find out that Doctrine has its own deprecation triggering mechanism, and they have to add (minimal) code along their bootstrapping path to make doctrine/* report deprecations in a way that they show up alongside Symfony deprecations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants