-
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
Add deprecation warnings for 2.7.x #7901
Conversation
3786701
to
f9a4258
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.
Build failures affect MySQL's quoting of collations: unrelated to this patch.
Somebody Can tell me, why you want to remove that a importants methods like clear/merge/detach in EM? It will be some replacement methods? Second question. PHPDoc tag @deprecated mean from which version of package the specified method will be removed. So deprecated and removed in 3.0 ? I dont think so. |
Mostly complexity and edge cases that are better solved via simpler
The deprecated API will be removed (and we also already did remove a lot of it) in |
I will never understand your approach. You don't have a good standard of changes that you can change for anything ... in my humble opinion I think that these methods are very important, they work very well and getting rid of them will prevent you from raising to version 3.0 - put yourself in the places of many programmers for whom the problem there will be a raise to 3.0. In my case, rather not possible because I use merge / clear / detach myself - and since you have stated in PHPDoc that there will be no alternative methods - praise to you! In Symfony, if they remove something, they at least give a replacement method. |
In many of the removed endpoints, the alternative is effectively "stop doing X", where "X" is identified as a problem. Yes, this means that upgrading will require design changes in your code: that's something that was considered. We don't take decisions in a rushed nor uninformed way: this has been discussed and agreed upon when keeping in mind that there are thousands (potentially millions) of consumers of the library. |
Okey. Last one. Can you show and explain me a equivalent code to replace a merge/clear/detach methods? Thanks. |
There is NOT equivalent code: we removed these methods because people running into very bad bugs due to very very complex state permutations that shouldn't happen in first place. |
|
||
## Extending `EntityManager` is deprecated | ||
|
||
Final keyword will be added to the `EntityManager::class` in Doctrine 3.0 in order to ensure that EntityManager |
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.
Currently, DoctrineBundle generates a proxy class (using ocramius/proxy-manager
) for the entity manager, to allow resetting the entity manager (allowing to inject the entity manager in other services without having to kill the whole PHP process to rebuild all services in case an error occurs in the ORM). Will Doctrine ORM 3.0 allow reopening an entity manager instance (which of course involve it will be cleared) ? If no, this change means that using the EntityManager in a service used by a long-running process (a RabbitMQ consumer for instance) won't be possible anymore, which is quite impactful.
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 architecture in v3 is quite different. The design we have been discussing is that each transaction will use a different UoW instance. This promotes better isolation and removes the need for em to be closed (in theory). There are still things to be addressed on this but that's the gist.
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.
well, if an em does not get closed on failure, then that's fine.
for |
@Ocramius my existing use case for detach is a process where I'm iterating over object results for a big result set, and detaching objects once I don't need them anymore (this process is never flushing the unit of work btw, I'm only reading in there). This detaching allows to remove the memory reference to this object from the unit of work so that the object can be destructed by PHP. What is the expected replacement for such usage of |
@stof $query = $em->createQuery(' ... ');
foreach ($query->iterate() as $result) {
// Do whatever is needed with $result
// ...
// Free resources:
unset($result[0]);
$em->clear();
} Regarding the relations, they would be loaded again sure. Caching should help on this (also available in v2.6). |
@lcobucci no it does not, because it also clears any other entity that might have been loaded earlier for this processing (and SLC is not an option for me, because some of these objects are also modified by direct SQL in some batch processing, so the SLC would contain the wrong info unless I also manage it myself which seems insane). |
I try myself to replace a detach method in my projects but it's hard :/ |
@stof have you considered enabling the SLC using the That almost fully mimics the behaviour of the identity map, the only missing piece is the hydration. However, hydrating in an iteration like that should be quite cheap. Our main goal with that move is to protect the integrity of the UoW, which is an internal component of the ORM. No application should rely on it for optimisation purposes, caching is meant to address that concern. |
@lcobucci but in my case, I want to stop tracking only my entities in the big list that I process. For other objects that I use in my processing, keeping them in the identity map is a good idea, as it ensures that I can use |
That's a very interesting idea, and could be done in future for sure. As @lcobucci stated though:
|
Well, I'm not relying on the identity map for optimization purposes. that's precisely why using an ArrayCache as SLC does not fit me. I need to rely on the identity for other entities than the one I'm detaching during my processing. clearing+ in-memory SLC will optimize the loading of data, but won't preserve identity. |
@stof Read only sort of exists, but not as much as I remembered. I thought the following was possible: $query->setHint(Query::HINT_READ_ONLY, true); But that was removed during beta. I added read only objects later, but they are required to be managed manually: $entityManager->getUnitOfWork()->markReadOnly(entity); Essentially what we just need to make the query hint automatically set entities as read only. Read only objects are not considered during compute change sets. |
@beberlei but they are still referenced in the identity map. My issue is not about the size of computing the change set (this code does not flush at all). It is about avoiding to keep unnecessary objects in memory after processing them is done. |
…gin-master v2.7.0 [](https://travis-ci.org/doctrine/orm) This release solves Symfony 5.0 compatibility issues, some small improvements, and adds various deprecation notices. Please read carefully the [upgrade to 2.7 notes](https://github.com/doctrine/orm/blob/2.7/UPGRADE.md#upgrade-to-27) to know more about the reasons and how to fix the deprecation messages. --- - Total issues resolved: **1** - Total pull requests resolved: **15** - Total contributors: **10** Deprecation ----------- - [7911: Be explicit about which Doctrine package in message](doctrine#7911) thanks to @lcobucci - [7909: Add deprecation messages](doctrine#7909) thanks to @lcobucci - [7901: Add deprecation warnings for 2.7.x](doctrine#7901) thanks to @lcobucci - [7701: Split and deprecate AbstractQuery#useResultCache()](doctrine#7701) thanks to @someniatko CI -- - [7904: Make sure composer files are valid](doctrine#7904) thanks to @greg0ire - [7600: &doctrine#91;2.7&doctrine#93; CI: Test against PHP 7.4snapshot instead of nightly (8.0)](doctrine#7600) thanks to @Majkl578 Improvement ----------- - [7876: Fix compat of commands with Symfony 5](doctrine#7876) thanks to @nicolas-grekas - [7829: Skip Paginator LIMIT subquery and WHERE IN if query do not have LIMIT](doctrine#7829) thanks to @Seb33300 - [7723: Allow Symfony 5.0](doctrine#7723) thanks to @nicolas-grekas - [7710: Prettified arrays in tool command orm:mapping:describe](doctrine#7710) thanks to @rtek - [7340: Fix config template for PHPUnit >= 7.2](doctrine#7340) thanks to @guilliamxavier BC Break,Improvement -------------------- - [7863: Paginator: Skip limit subquery if not required](doctrine#7863) thanks to @Seb33300 Documentation ------------- - [7382: Update homepage](doctrine#7382) thanks to @Majkl578 Bug --- - [7326: Cherry-pick doctrine#7307 to fix remaining usages of deprecated ClassLoader and Inflector from doctrine/common](doctrine#7326) thanks to @nicolas-grekas - [7079: Fix getJoinTableName for sqlite with schema attribute](doctrine#7079) thanks to @mairo744 BC Break,Deprecation,Improvement -------------------------------- - [6803: Deprecation of EntityManager copy method](doctrine#6803) thanks to @SenseException
In one of my project we are facing the same situation described by @stof in #7901 (comment), and loved the suggestion in #7901 (comment)
Is there any work being done in that direction that we can help with? How did you solve it @stof ? |
the usecase of @thePanz and me is that we need to read (potentially lots of) entities that we know we don't intend to change, and we also don't need doctrine to cache them for us. at the same time, we have entities that we want to update and flush. if i read the code in the 2.9.x branch correctly, there are mainly 2 places that might matter to us:
we are motivated to contribute the feature, but of course we first need to figure out if the maintainer consider it a use case they want to support. if so, i suggest we create a new issue to discuss where to implement the functionality. |
I haven't solved it yet. For now, I'm still using the deprecated |
i chreated #8429 to further discuss the issue and think about solutions |
This recovers the great work done by @Majkl578 in #6869 but without using phpunit-bridge stuff to do the assertions.