-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Deprecate EntityManager::create()
#9961
Conversation
c58da45
to
f6cd5e8
Compare
Can you also check the docs for necesarry changes? I am unsure about this. While your argument rings true, if we are on a greenfield project, we are not snd this method is not expensive to maintain, but will avoid breaking not only a lot of vode, but also tutorials, blog posts, books, ... |
Marking as draft for now. The documentation indeed deserves an update.
I don't believe that this is the case, actually. Usually, the EM is initialized once at a central point in your application. This is the one piece of code that you need to apply a trivial fix to. Even more though, in applications that use some kind of framework integration like DoctrineBundle. In that case, this integration code will be patched and people won't even notice.
Those will all still work for ORM 2. Deprecated code is not broken code. ORM 3 will be a little different than ORM 2 and I think it's acceptable that blogposts and tutorials need to be adjusted for a new major version. My rationale here is that the ORM and the DBAL are not as inseparable anymore as they maybe used to be. The |
f6cd5e8
to
da2e462
Compare
@@ -156,15 +156,15 @@ class EntityManager implements EntityManagerInterface | |||
* Creates a new EntityManager that operates on the given database connection | |||
* and uses the given Configuration and EventManager implementations. | |||
*/ | |||
public function __construct(Connection $conn, Configuration $config) | |||
public function __construct(Connection $conn, Configuration $config, ?EventManager $eventManager = null) |
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.
The class-level phpdoc comment refers to the factory method your deprecated, please update it.
Is this still a draft or can it be changed into a PR? |
Still a draft because I'm updating the docs atm. |
da2e462
to
9cb584c
Compare
9cb584c
to
e6eea74
Compare
Ready. I chose to resurrect this PR because the latest deprecation in DBAL (removal of the EventManager integration) force us to change the |
* 2.14.x: Deprecate EntityManager::create() (doctrine#9961) Address deprecation of SchemaDiff::toSaveSql() Address deprecation of SchemaDiff::toSql() Use error style for notifications Fix calls to AbstractSchemaManager::createSchema() (doctrine#10165) Fix build with DBAL 3.5 (doctrine#10163) Adjust comments (doctrine#10160) Deprecate methods related to the annotation driver Use correct link Deprecate annotations Remove trailing whitespace Migrate more documentation towards attributes Remove wrong sentence Do not export phpstan stuff (doctrine#10154)
Please update docs as official documentation on creating an EntityManager actually tells us to use the Thanks |
@frsmoray You are linking to the 2.13.x docs. This was perfectly valid in 2.13.x
Use a nicer tone, this is not OK. |
Sorry, mistakenly got pulled 2.14 onto my project. Expeting to be 2.13 as usual.
It's written text. Tone is a perception on spoken words. Apart from my mistake searching wrong docs, and 2.13 docs having nothing to do with any deprecation advice on that purpose, there is no deprecation notice at all there. If you think it twice, you may "find another tone" in these words
Thanks for the help :) |
2.13 is no longer maintained, so if you upgrade, that's not a bad things, really.
Wanna nit-pick? From https://www.merriam-webster.com/dictionary/tone :
(emphasis mine) Note that I didn't have to discard several web pages until finding one that fits my argument, it's literally the first one I clicked.
You're right, but what's your point? Our policy is to document those in
I can do that, and on your end, you can be more careful when addressing people that provide you with software updates for free. I guess you meant well, but having to do that assumption for everyone can be a bit exhausting, don't you think? |
@@ -127,7 +127,8 @@ the targetEntity resolution will occur reliably: | |||
// Add the ResolveTargetEntityListener | |||
$evm->addEventListener(Doctrine\ORM\Events::loadClassMetadata, $rtel); | |||
|
|||
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config, $evm); | |||
$connection = \Doctrine\DBAL\DriverManager::createConnection($connectionOptions, $config, $evm); |
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.
is this supposed to be getConnection
? There doesn't seem to be a createConnection
function in this class
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.
Yes.
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.
Yes, it became getConnection by now. It's totally okay if you want to create a pull request with changes for that.
If you haven't done a pull request for Doctrine, you might find this guide helpful:
https://www.doctrine-project.org/contribute/index.html
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 #11104
Now that the entity manager's constructor is public, why not make it the only way to construct an EM?
The only additional feature that
create()
has is that you can pass the connection parameters instead of a real DBAL connection. However, I believe that bootstrapping the DBAL connection is a concern that belongs into the DBAL library and the DBAL'sDriverManager
class already does a fine job in that regard.This is why I believe that we shouldn't need the
create()
method anymore.